Chaining Observable Subscriptions
-
23-09-2019 - |
Question
Is there a shorthand version of this. I want to call one sequence and then when it is finished call another.
var seq1 = Observable.Range(1, 20);
var seq2 = Observable.Range(21, 20);
seq1.Subscribe(
i => Console.WriteLine(i),
() => seq2.Subscribe(i => Console.WriteLine(i)));
Solution
It's not entirely clear to me what you're trying to do (and I don't have the docs to hand) but is Observables.Concat what you're after?
var seq1 = Observable.Range(1, 20);
var seq2 = Observable.Range(21, 20);
var both = seq1.Concat(seq2);
both.Subscribe(i => Console.WriteLine(i));
(I'm just checking that this actually works :)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow