DestroyRef
Class
stable
DestroyRef
lets you set callbacks to run for any cleanup or destruction behavior.
The scope of this destruction depends on where DestroyRef
is injected. If DestroyRef
is injected in a component or directive, the callbacks run when that component or
directive is destroyed. Otherwise the callbacks run when a corresponding injector is destroyed.
onDestroy
() => void
Registers a destroy callback in a given lifecycle scope. Returns a cleanup function that can be invoked to unregister the callback.
@paramcallback
() => void
@returns
() => void
destroyed
boolean
Indicates whether the instance has already been destroyed and whether its onDestroy
callbacks have executed.
Jump to details