I have two hot observables which I do not want to miss any notification
1st observable produces numbers
1-2-3-4
and 2nd strings
a-b
I am looking for a way to zip them to produce the next output
a-1 b-2 a-3 b-4 a-5
So what I want is to repeat the 2nd stream indefinitely until the first stream is unsubscribed. I tried something like the next test which produces the desired output. However I do not Repeat
for ever as I do not know how to stop in order to test the results. In addition I used a ReplaySubject
which I completed manually meaning that I cannot receive any new notifications.
class MyClass:ReactiveTest{
[Fact]
public void MethodName4() {
var strings = new ReplaySubject<string>();
var testScheduler = new TestScheduler();
testScheduler.Schedule("", TimeSpan.FromTicks(10), (scheduler, s) => {
strings.OnNext("a");
strings.OnNext("b");
strings.OnCompleted();
});
var numbers = testScheduler.CreateHotObservable(OnNext(100, 1), OnNext(200, 2), OnNext(300, 3), OnNext(400, 4), OnNext(500, 5));
numbers.Zip(Observable.Defer(() => strings).Repeat(3), (i, s) => (i, s)).Subscribe();
testScheduler.AdvanceBy(500);
}
}