feat(core/linker): add SimpleChanges type to lifecycle_hooks to simplify OnChanges signature
Closes #8557
This commit is contained in:
@ -11,6 +11,7 @@ export {
|
||||
|
||||
WrappedValue,
|
||||
SimpleChange,
|
||||
SimpleChanges,
|
||||
PipeTransform,
|
||||
DefaultIterableDiffer,
|
||||
IterableDiffers,
|
||||
|
@ -41,6 +41,7 @@ export {
|
||||
looseIdentical,
|
||||
uninitialized
|
||||
} from './change_detection_util';
|
||||
export {SimpleChanges} from '../metadata/lifecycle_hooks';
|
||||
|
||||
/**
|
||||
* Structural diffing for `Object`s and `Map`s.
|
||||
|
@ -11,6 +11,15 @@ export enum LifecycleHooks {
|
||||
AfterViewChecked
|
||||
}
|
||||
|
||||
/**
|
||||
* A `changes` object whose keys are property names and
|
||||
* values are instances of {@link SimpleChange}. See {@link OnChanges}
|
||||
*/
|
||||
export interface SimpleChanges {[propName: string]: SimpleChange};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export var LIFECYCLE_HOOKS_VALUES = [
|
||||
LifecycleHooks.OnInit,
|
||||
LifecycleHooks.OnDestroy,
|
||||
@ -53,7 +62,7 @@ export var LIFECYCLE_HOOKS_VALUES = [
|
||||
* class MyComponent implements OnChanges {
|
||||
* @Input() myProp: any;
|
||||
*
|
||||
* ngOnChanges(changes: {[propName: string]: SimpleChange}) {
|
||||
* ngOnChanges(changes: SimpleChanges) {
|
||||
* console.log('ngOnChanges - myProp = ' + changes['myProp'].currentValue);
|
||||
* }
|
||||
* }
|
||||
@ -72,7 +81,7 @@ export var LIFECYCLE_HOOKS_VALUES = [
|
||||
* bootstrap(App).catch(err => console.error(err));
|
||||
* ```
|
||||
*/
|
||||
export abstract class OnChanges { abstract ngOnChanges(changes: {[key: string]: SimpleChange}); }
|
||||
export abstract class OnChanges { abstract ngOnChanges(changes: SimpleChanges); }
|
||||
|
||||
/**
|
||||
* Implement this interface to execute custom initialization logic after your directive's
|
||||
|
Reference in New Issue
Block a user