angular-update-guide
angular-update-guide copied to clipboard
Missing update hint when updating to Angular 9
Since Ivy doesn't support patching lifecycle hooks there should be one more migration checkbox hint to remind users of that fact.
I used to have a small function to automatically unsubscribe from observables
export function componentDestroyed(component: Destroyable): Subject<any> {
if (component.unsubscribeSubject$) {
return component.unsubscribeSubject$;
}
const oldNgOnDestroy = component.ngOnDestroy;
component.unsubscribeSubject$ = new Subject();
component.ngOnDestroy = () => {
if (oldNgOnDestroy) {
oldNgOnDestroy.apply(component);
}
component.unsubscribeSubject$.next(undefined);
component.unsubscribeSubject$.complete();
};
return component.unsubscribeSubject$;
}
which was used like takeUntil(componentDestroyed(this))
in Angular 9 that does not work anymore.