DEV Community

Discussion on: Loading Components Dynamically in Angular 9 with Ivy

Collapse
 
exequiel09 profile image
Exequiel Ceasar Navarrete • Edited

Hello, I was looking into this post. I just want to point out that in this line snippet of code above, the takeUntil should come last before anything else in the observable pipeline. See rxjs-no-unsafe-takeuntil rule in this package: npmjs.com/package/rxjs-tslint-rules. But still, awesome content! :)

 this.profileService.isLoggedIn$
      .pipe(
        takeUntil(this.destroySubject),
        mergeMap(isLoggedIn =>
          this.profileService.loadComponent(viewContainerRef, isLoggedIn)
        )
      )
      .subscribe();
Collapse
 
danmt profile image
Daniel Marin

You're right my friend!!! Very good catch, I should've used rxjs-tslist-rules...

Thanks for reading and sharing your feedback!!