observeOn

ObserveOnObservable!(TObservable, TScheduler)
observeOn
(
TObservable
TScheduler : Scheduler
)
(
auto ref TObservable observable
,
TScheduler scheduler
)

Examples

1 import std.concurrency;
2 import rx.subject;
3 
4 auto subject = new SubjectObject!int;
5 auto scheduler = new LocalScheduler;
6 auto scheduled = subject.observeOn(scheduler);
7 
8 import std.array : appender;
9 
10 auto buf = appender!(int[]);
11 auto observer = observerObject!int(buf);
12 
13 auto d1 = scheduled.subscribe(buf);
14 auto d2 = scheduled.subscribe(observer);
15 
16 subject.put(0);
17 assert(buf.data.length == 2);
18 
19 subject.put(1);
20 assert(buf.data.length == 4);