1 import std.range : iota;
2
3 auto obs = from(iota(10));
4 auto res = new int[10];
5 auto d = obs.subscribe(res[]);
6 scope (exit)
7 d.dispose();
8
9 assert(res.length == 10);
10 assert(res[0] == 0);
11 assert(res[9] == 9);
1 import std.range : iota;
2
3 auto obs = iota(10).asObservable();
4 auto res = new int[10];
5 auto d = obs.subscribe(res[]);
6 scope (exit)
7 d.dispose();
8
9 assert(res.length == 10);
10 assert(res[0] == 0);
11 assert(res[9] == 9);
1 import rx;
2 import std.range : iota;
3
4 auto observable = iota(10).asObservable();
5 auto observer = new CounterObserver!int;
6
7 auto disposable = observable.subscribe(observer);
8 scope (exit)
9 disposable.dispose();
10
11 assert(observer.putCount == 10);
12 assert(observer.completedCount == 1);