CopyPastor

Detecting plagiarism made easy.

Score: 0.8059852123260498; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-03-11
by Thanh Le

Original Post

Original - Posted on 2016-04-22
by Much Overflow



            
Present in both answers; Present only in the new answer; Present only in the old answer;

subscribe(...) will return a Subscription Try to edit your code, make method return a Subscription like this
public Subscription getAuthObservable() { return NetworkClient.getRetrofit().create(NetworkInterface.class) .getAuthDetails("application/x-www-form-urlencoded", new AuthRequestDetails().getAuthRequestDetails()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<Response<Void>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(Response<Void> voidResponse) { String access_token_received = voidResponse.headers().get("access_token"); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); }
Yes, you can use flatmap for this exact purpose. See the below example (Assuming your service A returns `Observable<FooA>` and service B returns `Observable<FooB>`)
api.serviceA() .flatMap(new Func1<FooA, Observable<FooB>>() { @Override public Observable<FooB> call(FooA fooA) { // code to save data from service A to db
// call service B return api.serviceB(); } }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber<FooB>() { @Override public void onCompleted() { }
@Override public void onError(Throwable e) { }
@Override public void onNext(FooB fooB) { // code to save data from service B to db
} });

        
Present in both answers; Present only in the new answer; Present only in the old answer;