Skip to content

Commit

Permalink
feat(core): expose onDestroy on ApplicationRef (#49677)
Browse files Browse the repository at this point in the history
This change exposes the onDestroy callback on the ApplicationRef
as the public API. It is useful for cases where people need to
execute cleanup logic on application teardown.

Closes #49087

PR Close #49677
  • Loading branch information
pkozlowski-opensource authored and dylhunn committed Apr 3, 2023
1 parent 7870fb0 commit a5f1737
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 1 addition & 0 deletions goldens/public-api/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class ApplicationRef {
detachView(viewRef: ViewRef): void;
get injector(): EnvironmentInjector;
readonly isStable: Observable<boolean>;
onDestroy(callback: () => void): VoidFunction;
tick(): void;
get viewCount(): number;
// (undocumented)
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/application_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,6 @@ export class ApplicationRef {
*
* @param callback A callback function to add as a listener.
* @returns A function which unregisters a listener.
*
* @internal
*/
onDestroy(callback: () => void): VoidFunction {
(typeof ngDevMode === 'undefined' || ngDevMode) && this.warnIfDestroyed();
Expand Down

0 comments on commit a5f1737

Please sign in to comment.