makeObserver

The helper for the own observer.

  1. auto makeObserver(void delegate(E) doPut, void delegate() doCompleted, void delegate(Exception) doFailure)
  2. auto makeObserver(void delegate(E) doPut, void delegate() doCompleted)
  3. auto makeObserver(void delegate(E) doPut, void delegate(Exception) doFailure)
    makeObserver
    (
    E
    )
    (
    void delegate(
    E
    )
    doPut
    ,
    void delegate(
    Exception
    )
    doFailure
    )

Examples

1 int countPut = 0;
2 int countCompleted = 0;
3 int countFailure = 0;
4 
5 auto observer = makeObserver((int) { countPut++; }, () { countCompleted++; }, (Exception) {
6     countFailure++;
7 });
8 
9 .put(observer, 0);
10 assert(countPut == 1);
11 
12 observer.completed();
13 assert(countCompleted == 1);
14 
15 observer.failure(null);
16 assert(countFailure == 1);