java - RxJava; How to emit observables synchronously -


i want synchronously emit 2 observable objects (which asynchronous), 1 after other returns first emitted observable object. if first 1 fails, should not emit second one.

let's have 1 observable signs user in, , observable automatically selects user's account, after signing in.

this tried:

public observable<accesstoken> signinandselectaccount(string username, string password) {      observable<accesstoken> ob1 = ...; // sign in.     observable<account> ob2 = ...; // select account.       return observable.zip(             ob1,             ob2,             new func2<accesstoken, account, accesstoken>() {                 @override                 public accesstoken call(accesstoken accesstoken, account account)                 {                      return accesstoken;                 }             }); } 

this unfortunately not work use case. emit/call both observables parallel, starting 'ob1'.

did encounter similar use case? or has idea on how make observables wait eachother in synchronous way, first emitted can returned?

thanks in advance.

there no such term "wait" in reactive programming. need think creating of data stream, 1 observable triggered another. in case after receiving token need receive account. this:

observable<account> accountobservable = observable.create(new observable.onsubscribe<accesstoken>() {     @override public void call(subscriber<? super accesstoken> subscriber) {         subscriber.onnext(new accesstoken());         subscriber.oncompleted();     } }).flatmap(accesstoken -> observable.create(new observable.onsubscribe<account>() {     @override public void call(subscriber<? super account> subscriber) {         subscriber.onnext(new account(accesstoken));         subscriber.oncompleted();     } })); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -