I’ve got three IObservable of types Foo, Bar and Baz. In addition, there is a method defined as:
void DoWork(Foo foo);
The IObservable are defined elsewhere as Subject and OnNext is called from time to time.
Whenever new data is available (defined by some Where queries), I want to call the DoWork method with the latest Foo value. If no Foo values were generated the method should not be called.
What is the easiest way to do that?
To be more specific, see the following example. I’d like to call DoWork when bar or baz change, with the latest foo (f.id == 1):
void Wire(IObservable<Foo> foo, IObservable<Bar> bar, IObservable<Baz> baz)
{
foo.Where(f => f.Id == 1)
.Subscribe(f => DoWork(f));
}
This works for me: