summaryrefslogtreecommitdiffstats
blob: 1821cb0fe654c4e67197a9b3dc4c63c3c0957fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright (c) 2010-2015, Isode Limited, London, England.
 * All rights reserved.
 */
package com.isode.stroke.signals;


/**
 * An approximation of the boost::signals system, although a little more warty.
 */
public final class Signal extends BaseSignal {

    public SignalConnection connect(Slot bind) {
        return addBind(bind);
    }

    public SignalConnection connect(final Signal target) {
        return connect(new Slot() {
            public void call() {
                target.emit();
            }
        });
    }

    public void emit() {
        final BaseSlot[] binds = getBinds();
        if (binds == null) {return;}
        for (BaseSlot bind : binds) {
            ((Slot)bind).call();
        }
    }

}