Hi,
I try to implements this function:
mainBehavior$
.pipe(
switchMap((mainBehavior) =>
combineLatest([secondBehavior$, thirdBehavior$]).pipe(
tap(([secondBehavior, thirdBehavior]) =>
console.log(
'PROBLEM: ',
mainBehavior,
secondBehavior,
thirdBehavior
)
)
)
)
)
.subscribe();
But if i next the second or third Behavior, them trigger the mainBehavior.
So i implements this:
function getSecondBehavior() {
return secondBehavior$.getValue();
}
function getThirdBehavior() {
return thirdBehavior$.getValue();
}
mainBehavior$
.pipe(
filter((mainBehavior) => !!mainBehavior),
map((mainBehavior) => [
mainBehavior,
getSecondBehavior(),
getThirdBehavior(),
]),
tap(([mainBehavior, secondBehavior, thirdBehavior]) =>
console.log('FIXED: ', mainBehavior, secondBehavior, thirdBehavior)
)
)
.subscribe();
Do you know how to edit my first function for not doing this workaround?
Link to Stackblitz for reproduce: https://stackblitz.com/edit/rxjs-8ay9ov?file=index.ts
Top comments (0)