java - RXJava - combineLatest without losing any result -


i want combine 2 observables, 1 emits n items , other 1 1.

combinelatest wait until both observables have @ least emitted 1 item , combines latest emitted items until both observable have finished. consider following chronologically order:

  • observable -> emits result a1
  • observable -> emits result a2
  • observable b -> emits result b1

combinelatest combine result 2 of observable 1 result 1 of observable 2 (can tester here easily: http://rxmarbles.com/#combinelatest).

what need

i need combine items of 2 observables, no matter 1 faster. how can that?

result should (always, independent of observable starts emitting items first!):

  • a1 combined b1
  • a2 combined b1

note untested:

create replaysubject observable sequence a. each value emits on sequence b combine value replay subject create new observable of pair<a, b>. flat map these observables , return result.

public static <a, b> observable<pair<a, b>> permutation(     observable<a> observablea,      observable<b> observableb,  ) {     replaysubject<a> subjecta = replaysubject.create();     observablea.subscribe(subjecta::onnext);     return observableb.flatmap(b -> subjecta.map(a -> pair.of(a, b))); } 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -