makeObserver

The helper for the own observer.

  1. auto makeObserver(void delegate(E) doPut, void delegate() doCompleted, void delegate(Exception) doFailure)
    makeObserver
    (
    E
    )
    (
    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)

Examples

int countPut = 0;
int countCompleted = 0;
int countFailure = 0;

auto observer = makeObserver((int) { countPut++; }, () { countCompleted++; }, (Exception) {
    countFailure++;
});

.put(observer, 0);
assert(countPut == 1);

observer.completed();
assert(countCompleted == 1);

observer.failure(null);
assert(countFailure == 1);

Meta