I would like to combine multiple observables, where each one returns a single Update object, into a single dictionary object.
Here is a sample of what I am trying to achieve:
private IObservable<IDictionary<string, IUpdate>> CreateUpdateStreams(Product product)
{
var codeObservables = product.Codes.Select(code => CreateUpdateStream(code)).ToList();
//???
return pointObs.Merge().Select(update => ...);
}
private IObservable<IUpdate> CreateUpdateStream(string code)
{
...
//return an observable of IUpdate
}
- I want to combine all of the IUpdates as they come in into a single, updating dictionary where the key = Code and Value = IUpdate
- The caller of CreateUpdateStreams will know the Product and want to make changes to some properties of each Code object depending on the update. For example
Product = Foo
Product.Codes = {Code1, Code2, Code3}
IDictionary = {Code1, "a"}, {Code2, "b"}, {Code3, "c"}
Depending on the value of the updates (in this case a/b/c) a different change will be made to the corresponding Code, for example set a property like Code.State = "a", etc.
Since each of the codeObservables will update at different rates, Merge seemed like the sensible starting point. I am not sure though how to have the updates from the individual observables update a dictionary object, which retains past values.