I have the following block of code for my nested observable and am trying to get observable<user[]>
which this code is not doing:
return this.findUser(term).map( users => {
return users.map( user => this.getLastLogin(user.user_id).map( last_login => {
user.last_login = last_login;
return user;
}));
});
findUser
returns Observable<User[]>
and getLastLogin
returns Observable<number>
.
I'm basically hoping to fetch a list of users and then update this with the information from another value.
Right now the code above is returning <Observable<Observable<User>[]>
.
I thought I could replace the initial map
with flatMap
but this turns the object into <Observable<Observable<User>>
.
The RxJS documentation is a little hard to decipher so I'm not sure what combination of switch
, forkJoin
or flatMap
will get me to what I need.
How can I change the code to just return an Observable<User[]>
?
mergeMap
result in a non-deterministic order? Would the order depend upon which to-be-merged observables emit first? – Dowson