|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
// tslint:disable: max-line-length
|
|
|
|
|
import { Observable, Subject } from 'rxjs';
|
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
@ -5,13 +6,16 @@ function isFunction(value) {
|
|
|
|
|
return typeof value === 'function';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated no longer working, please use SubscriptionService (https://docs.abp.io/en/abp/latest/UI/Angular/Subscription-Service) instead.
|
|
|
|
|
*/
|
|
|
|
|
export const takeUntilDestroy = (componentInstance, destroyMethodName = 'ngOnDestroy') => <T>(
|
|
|
|
|
source: Observable<T>
|
|
|
|
|
source: Observable<T>,
|
|
|
|
|
) => {
|
|
|
|
|
const originalDestroy = componentInstance[destroyMethodName];
|
|
|
|
|
if (isFunction(originalDestroy) === false) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`${componentInstance.constructor.name} is using untilDestroyed but doesn't implement ${destroyMethodName}`
|
|
|
|
|
`${componentInstance.constructor.name} is using untilDestroyed but doesn't implement ${destroyMethodName}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (!componentInstance['__takeUntilDestroy']) {
|
|
|
|
|