Splitting the data of one observable into multiple observables

Docu-Post:

In a recent thread on the matrix, we thought about the question, how to split data transported over a reactive flow into multiple events, depending on data size.
several solutions where proposed. splitting the data according to a given size can be done using the GroupBy (Length) node from the Spread category, in combination with an Add (Spread) node, which appends the remainder of the split to the Spread. The resulting is a Spread of Spreads, where each element will be transformed to an individual Observable event. Several equally working strategies were supposed:

the simplest solution (in node count) proposed by @woei appears to be a combination of Select (Many) and a ToObservable node (from the System.Reactive.Observable category, which has to be manually referenced):

@woei writes:
SelectMany + toObservable<IEnumerable>
where the to observable is directly imported instead of the forwarded node. sure, there is a reason why it’s not exposed directly, but i don’t know/remember why. was something about the observable source switching while patching if i remember correctly

a similar solution using the available ToObservable (Sequence) node from CoreLib does not work in combination with Select (many):
grafik

other working solutions were suggested by @tobyk, @sebl and myself:
grafik
here a combination of ForEach (Reactive) ToObservable(Sequence) and Switch (Reactive) does give the expected result.

Building an Observable Sequence using a standard ForEach with Start [Reactive.Observable] inside and Merge [Reactive.Observable] works as well.
grafik

Using Channels it is possible to get a similar result:
grafik

Big thanks to @tobyk , @sebl and @woei for the insights!
ReactiveOnSpreadIdea_v3.vl (76.9 KB)

5 Likes