tee

template tee(alias f)
TeeObservable!(f, TObservable, TObservable.ElementType)
tee
(
TObservable
)
(
auto ref TObservable observable
)

Examples

1 import rx.subject : SubjectObject;
2 
3 auto sub = new SubjectObject!int;
4 
5 import std.array : appender;
6 
7 auto buf1 = appender!(int[]);
8 auto buf2 = appender!(int[]);
9 
10 import rx.algorithm : map;
11 
12 auto disposable = sub.tee!(i => buf1.put(i))().map!(i => i * 2)().subscribe(buf2);
13 
14 sub.put(1);
15 sub.put(2);
16 disposable.dispose();
17 sub.put(3);
18 
19 import std.algorithm : equal;
20 
21 assert(equal(buf1.data, [1, 2]));
22 assert(equal(buf2.data, [2, 4]));