subscribeOn

SubscribeOnObservable!(TObservable, TScheduler)
subscribeOn
(
TObservable
TScheduler : Scheduler
)
(
auto ref TObservable observable
,
auto ref TScheduler scheduler
)

Examples

1 import rx.observable : defer;
2 
3 auto sub = defer!int((Observer!int observer) {
4     .put(observer, 100);
5     return NopDisposable.instance;
6 });
7 auto scheduler = new LocalScheduler;
8 
9 auto scheduled = sub.subscribeOn(scheduler);
10 
11 int value = 0;
12 auto d = scheduled.doSubscribe((int n) { value = n; });
13 scope (exit)
14     d.dispose();
15 
16 assert(value == 100);
1 import rx.observable : defer;
2 import rx.util : EventSignal;
3 
4 auto sub = defer!int((Observer!int observer) {
5     .put(observer, 100);
6     return NopDisposable.instance;
7 });
8 auto scheduler = new TaskPoolScheduler;
9 auto scheduled = sub.subscribeOn(scheduler);
10 
11 int value = 0;
12 auto signal = new EventSignal;
13 auto d = scheduled.subscribe((int n) { value = n; signal.setSignal(); });
14 scope (exit)
15     d.dispose();
16 
17 signal.wait();
18 assert(value == 100);