* Destroy the injector and release references to every instance or provider associated with it. * * Also calls the `OnDestroy` lifecycle hooks of every instance that was created for which a * hook was found.
()
| 268 | * hook was found. |
| 269 | */ |
| 270 | override destroy(): void { |
| 271 | assertNotDestroyed(this); |
| 272 | |
| 273 | // Set destroyed = true first, in case lifecycle hooks re-enter destroy(). |
| 274 | this._destroyed = true; |
| 275 | const prevConsumer = setActiveConsumer(null); |
| 276 | try { |
| 277 | // Call all the lifecycle hooks. |
| 278 | for (const service of this._ngOnDestroyHooks) { |
| 279 | service.ngOnDestroy(); |
| 280 | } |
| 281 | const onDestroyHooks = this._onDestroyHooks; |
| 282 | // Reset the _onDestroyHooks array before iterating over it to prevent hooks that unregister |
| 283 | // themselves from mutating the array during iteration. |
| 284 | this._onDestroyHooks = []; |
| 285 | for (const hook of onDestroyHooks) { |
| 286 | hook(); |
| 287 | } |
| 288 | } finally { |
| 289 | // Release all references. |
| 290 | this.records.clear(); |
| 291 | this._ngOnDestroyHooks.clear(); |
| 292 | this.injectorDefTypes.clear(); |
| 293 | setActiveConsumer(prevConsumer); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | override onDestroy(callback: () => void): () => void { |
| 298 | assertNotDestroyed(this); |
nothing calls this directly
no test coverage detected