/* Copyright IBM Corp. 2018 */ import { AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; import { Observable, PartialObserver, Subject, Subscribable, Subscription } from 'rxjs'; /** Base class that allows to register life cycle hooks. This class is supposed * to be subclassed before use. * * The 'ngXXX' methods override the methods from the Angular life cycle interfaces. If you overridde * any of these methods make sure to call the super method. * * The 'onXXX' methods expose observables that will be triggered when the life cycle method occurs. This is * a convenient way to register hooks in the constructor of a subclass without having to override any * method. * * The {@link #onOnDestroy} observable is especially useful, since it can be used as a termination signal for * automatic unsubscriptions via the {@link http://reactivex.io/documentation/operators/takeuntil.html} operation. * * Note that hooks such as `onOnInit` and `onOnDestroy` only fire once. If you depend on such a hook in an observable * chain more than once make sure to share the emissions (typically via `shareReplay` ) */ export declare abstract class AbstractLifeCycleComponent implements OnInit, OnDestroy, OnChanges, DoCheck, AfterContentInit, AfterContentChecked, AfterViewInit, AfterViewChecked { /** * @see AfterViewChecked * @override */ ngAfterViewChecked(): void; /** * @see AfterViewInit * @override */ ngAfterViewInit(): void; /** * @see AfterContentChecked * @override */ ngAfterContentChecked(): void; /** * @see AfterContentInit * @override */ ngAfterContentInit(): void; /** * @see DoCheck * @override */ ngDoCheck(): void; /** * @see OnChanges * @override */ ngOnChanges(changes: SimpleChanges): void; /** * @see OnInit * @override */ ngOnInit(): void; /** * @see OnDestroy * @override */ ngOnDestroy(): void; /** * @see AfterViewChecked * @return the observable representation of this callback */ protected readonly onAfterViewChecked: Observable; /** * @see AfterViewInit * @return the observable representation of this callback */ protected readonly onAfterViewInit: Observable; /** * @see AfterContentChecked * @return the observable representation of this callback */ protected readonly onAfterContentChecked: Observable; /** * @see AfterContentInit * @return the observable representation of this callback */ protected readonly onAfterContentInit: Observable; /** * @see DoCheck * @return the observable representation of this callback */ protected readonly onDoCheck: Observable; /** * @see OnChanges * @return the observable representation of this callback */ protected readonly onOnChanges: Observable; /** * @see OnInit * @return the observable representation of this callback */ protected readonly onOnInit: Observable; /** * @see OnDestroy * @return the observable representation of this callback */ protected readonly onOnDestroy: Observable; /** * Unsubscribes the given subscription in the ngOnDestroy method. This method exists for convenience only, * consider to use the {@link #safeSubscribe} method instead. * * @param aSubscription the subscription to unsubscribe on * * @deprecated use `takeUntil(onOnDestroy)` instead */ protected unsubscribeOnDestroy(aSubscription: Subscription): void; /*** * Returns a property descriptor for a setter that dispatches to the given subject. * The subject will automatically be completed and unsubscribed on the onDestroy method. The * resulting descriptor may be used to define input properties in the closure of the * constructor of a component. * * @param aSubject the subject * @return the property descriptor * * @deprecated use createSetter instead */ protected describeSetter(aSubject: Subject): PropertyDescriptor; /** * Subscribes to an observable and makes sure to clean the subscription in ngOnDestroy * to avoid memory leaks. * * @param aObservable the observable to subscribe to * @param aObserver the handler. If this value is a 'string', then the subscription will automatically update the respective * property on the instance. * @param error optional error handler * @param complete optional completion handler * * @deprecated use `takeUntil(onOnDestroy)` instead */ safeSubscribe(aObservable: Subscribable, aObserver?: PartialObserver | ((value: T) => void) | string, error?: (error: any) => void, complete?: () => void): void; } /** * Constructs a setter that is unregistered automatically in onDestroy * * @param aSubject the subject * @param aThis the component * * @return the descriptor */ export declare function createSetter(aSubject: Subject, aThis: AbstractLifeCycleComponent): PropertyDescriptor; /** * Constructs a getter that subscribes to a value * * @param aObservable the observable * @param aThis the component * @param aInitial the optional initial value * * @return the descriptor */ export declare function createGetter(aObservable: Observable, aThis: AbstractLifeCycleComponent, aInitial?: T): PropertyDescriptor;