ngx-mfe
Version:
A library for working with MFE in Angular in a plugin-based approach and with Angular routing.
44 lines (43 loc) • 1.19 kB
TypeScript
/**
* Strategy for changing the component's @Input() variable.
*/
export declare enum EChangesStrategy {
/**
* Called on every change.
*/
Each = 0,
/**
* Called only on the first change.
*/
First = 1,
/**
* Called on every change except the first.
*/
NonFirst = 2
}
export interface TrackChangesOptions {
/**
* Change strategy.
* @default EChangesStrategy.Each
*/
strategy?: EChangesStrategy;
/**
* Compare the previous value with the current one
* and execute the method only if the values differ.
*
* Values must be immutable, as values are compared by reference.
* @default false
*/
compare?: boolean;
}
/**
* Decorator of lifecycle hook ngOnChanges, that call specified method when changes prop (@Input) value.
* -------
*
* Method decorator.
*
* @param prop Variable name of Input, that will be call method when changes.
* @param methodName The name of the method that will be called when the variable changes.
* @param options Options.
*/
export declare function TrackChanges<T>(prop: string, methodName: string, options?: TrackChangesOptions): MethodDecorator;