Hi Ollie,
You could use Expand for this, although it's only available in Rx Experimental at the moment.
For example, if you wanted to expand a sequence by index you could do the following. Note that if you need to expand by data and not index, then simply remove the
Tuple projection.
var o = GetObservable();
var indexed = o.Select((value, index) => Tuple.Create(index, value));
var inserted = indexed.Expand(item =>
{
if (item.Item1 == 10)
{
return Observable.Range(1, 100).Select(value => Tuple.Create(10, value));
}
else
{
return Observable.Empty<Tuple<int, int>>();
}
})
.Select(item => item.Item2);
- Dave
http://davesexton.com/blog