How to get data from second stream by first?

49 Views Asked by At

I have tried to get data from BehSubject this.visible$ only in case when this.redraw$ happends.

It works, but if the this.visible$ is changed somewhere the prev stream again works. How to avoid it?

this.redraw$.pipe(mergeMap(() => this.visible$)).subscribe((userfavourite: UserFavourite[]) => {}

As solution I can do this:

this.redraw$.subcribe(() => {
   this.visible$.subscribe((userfavourite: UserFavourite[]) => {}
});
1

There are 1 best solutions below

0
Mrk Sef On BEST ANSWER

Maybe something like:

this.redraw$.pipe(
  withLatestFrom(this.visible$),
  map(([_,v]) => v)
).subscribe(visible => {
  /* Do Something */
});