Open airiciuc opened 7 years ago
Anyone watching this issue? I've hit this again and it's causing bugs so easily. Here is a simpler situation:
userSearchTemObserver
.flatMap((term) => userService.searchUsers(term))
.mergeMap((users) => Observable.forkJoin(users.map((user) => facebookService.getProfile(user))))
.subscribe((users) => {
if(!users.length) {
//here i want to handle the special case when no user found mathing the search term
//but the it will never get here because forkJoin doesn't emit if the users list is empty
....
} else {
...
}
});
I've got the same issue (using a map function returning a potentially empty array).
Assume the following scenario where you need a dynamic number of server calls (sometime is 0) and you need to execute some functionality when all of them are done.
Expected behavior:
processUpdate
function is never calledonUpdatesFinished
is called onceActual behavior:
processUpdate
function is never calledonUpdatesFinished
is nerver calledNote: Change
return [].map(v => Rx.Observable.return(v).map(u => processUpdate(u)));
toreturn [1, 2, 3].map(v => Rx.Observable.return(v).map(u => processUpdate(u)));
andonUpdatesFinished
is called once