2 observables declared with takeUntilDestroyed, when combined, require additional...

Discussão em 'Angular' iniciado por Fred2020, Setembro 9, 2024.

  1. Fred2020

    Fred2020 Guest

    I'm using takeUntilDestroyed to manage my subscriptions and avoid memory leaks. Within an injection context, variable declaration, I will have something like this

    mySubject1$ = new BehaviourSubject<void>(void 0);
    myData1$ = mySubject1$.pipe(takeUntilDestroyed(), switchMap(() => myService.getData1()));
    mySubject2$ = new BehaviourSubject<void>(void 0);
    myData2$ = mySubject2$.pipe(takeUntilDestroyed(), switchMap(() => myService.getData2()));


    In my constructor I want to combine these, do I need to use takeUntilDestroyed() again?

    constructor(){
    combineLatest([myData1$, myData2$]).pipe(takeUntilDestroyed())...
    }

    Continue reading...

Compartilhe esta Página