Dartlang rxdart – merge different type streams


here is my use case:

I have two different Observables:

Observable<MobileAdEvent> adEventStream;
Observable<Color> colorStream;

I need to receive notification when either of those two emits an event. zipWith does not work for me, since it waits until both streams has an event to emit. mergeWith also does not seem to work, since it expects both stream to be from the same type.
Any hints would be greatly appreciated,


What you want is combineLatest operator

Observable<Foo> foo;
Observable<Bar> bar;

final output = Observable.combineLatest2(foo, bar, (Foo foo, Bar bar) {
  // TODO: somehow merge them

Answered By – Rémi Rousselet

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.