Would i need to manually unsubscribe in OnDestroy if I did it this way (not @Effect) as you have described?
Yes, whenever you do explicit .subscribe() call, you are automatically responsible to call .unsubscribe(). Even better would be to use .pipe(takeUntil(onDestroy$)) which is declarative ;)
.subscribe()
.unsubscribe()
.pipe(takeUntil(onDestroy$))
awesome, thanks!
so then I would also need to do this, right?
ngOnDestroy() { this.onDestroy$.next(true); this.onDestroy$.unsubscribe(); }
ngOnInit() { this.source$.pipe(takeUntil(onDestroy$)).subscribe() } ngOnDestroy() { this.onDestroy$.next(true); this.onDestroy$.complete() }
CHeers!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Would i need to manually unsubscribe in OnDestroy if I did it this way (not @Effect) as you have described?
Yes, whenever you do explicit
.subscribe()
call, you are automatically responsible to call.unsubscribe()
. Even better would be to use.pipe(takeUntil(onDestroy$))
which is declarative ;)awesome, thanks!
so then I would also need to do this, right?
CHeers!