Given the following code.
EventLoopScheduler scheduler = new EventLoopScheduler(ts => new Thread(ts));
BehaviorSubject<int> subject = new BehaviorSubject<int>(0);
subject
.ObserveOn(scheduler)
.CombineLatest(Observable.Interval(TimeSpan.FromSeconds(1), scheduler), (x, y) => x)
.Subscribe(x => Debug.WriteLine(x));
subject.OnNext(1);
Why does it print?
0
1
0
1
0
1
...
Instead of:
0
1
1
1
1
1
...
First of all your output looks really strange. I would say both of them. I guess the output should be:
without
0. This is because of the first interval value will be produced in 1 second – definitely after you callsubject.OnNext(1);The other strage thing
BehaviourSubject<int>– is it the UK version of the BehaviorSubject(Of T) ? 🙂 If you have your ownBehaviourSubjectimplementation, then please extend your question with it.