Just need some clarification on documentation of takeUntilDestroyed operator, so reading this doc: https://angular.io/api/core/rxjs-interop/takeUntilDestroyed , I dont see any words that I should use takeUntilDestroyed without params only in "injection" context (I dont really know what does this means). So basicly "Otherwise, the current DestroyRef is injected." so I can use it every where in component, directive, service, etc.
So question is this documentation is not fully describe how injection happens or it is problem with me?
(Please dont put any link explaining how this operator works, I know exactly how it works and checked source code, question is about documentation understanding)
2
Answers
The injection context is explained in this doc. Basically, it’s a runtine context where a current injector is set and Angular is able to use for dependency injection.
takeUntilDestroyed
requires anDestroyREf
to schedule the observable completion. this can be done 2 ways:inject(DestroyRef)
.inject
requires of course an injection contextDestroyRef
as argument, so no injection context is required.In code: