I have two Observables with different generic types: Observable o1 and Observable o2
I was defined to o1 the onComplet() and onNext() functions and i want that when this Observable get their finish then the o2 can start.
I tryed the Observable.concat() but they have different types, so this approach doesn't work...
So How can i do this?
Use castAs
before concatWith
(and ignoreElements
can be useful too):
Observable<T> o1;
Observable<R> o2;
Observable<R> o3 =
o1.ignoreElements()
.castAs(R.class)
.concatWith(o2);
Or if you're working with generic types (thus can't use R.class
):
Observable<R> o3 = ((Observable<R>)(Observable<?>)
o1.ignoreElements())
.concatWith(o2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With