CompositeObserver

Constructors

this
this(Observer!E[] observers)

Members

Functions

add
CompositeObserver!E add(Observer!E observer)
completed
void completed()
failure
void failure(Exception e)
observers
Observer!E[] observers()
put
void put(E obj)
remove
Observer!E remove(Observer!E observer)
removeStrict
CompositeObserver!E removeStrict(Observer!E observer)

Static functions

empty
CompositeObserver!E empty()

Examples

1 int count = 0;
2 struct TestObserver
3 {
4     void put(int n)
5     {
6         count++;
7     }
8 }
9 
10 auto c1 = new CompositeObserver!int;
11 c1.put(0);
12 auto o1 = observerObject!int(TestObserver());
13 auto c2 = c1.add(o1);
14 c1.put(0);
15 assert(count == 0);
16 c2.put(0);
17 assert(count == 1);
18 auto c3 = c2.add(observerObject!int(TestObserver()));
19 c3.put(0);
20 assert(count == 3);
21 auto c4 = c3.remove(o1);
22 c4.put(0);
23 assert(count == 4);