Issue
I have 2 api calls that need to take place one after the other in sync.
I'm using the rxjs concat operator in order to accomplish the sync.
This works great but how do i return the data from both observables?
This is how i implement it:
const userId='someId';
this.restangular.one('users/generate-api-token').customPOST() // Will return an api token
.concatMap(({token}) => this.restangular.one(`users/${userId}/api-token-details`).get()) // Will return the token's detail
.map((data) => {
console.log(data) // I would like to get both token and details here
});
Solution
Use resultSelector function of concatMap
Rx.Observable.of('123')
.concatMap(ev => Rx.Observable.of('abc'), (x,y) => [x,y])
.subscribe(x => console.log(x));
Answered By - Julia Passynkova
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.