1
|
/**
|
2
|
* @license
|
3
|
* Copyright Google Inc. All Rights Reserved.
|
4
|
*
|
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
|
* found in the LICENSE file at https://angular.io/license
|
7
|
*/
|
8
|
import { SimpleChange } from '../change_detection/change_detection_util';
|
9
|
/**
|
10
|
* A `changes` object whose keys are property names and
|
11
|
* values are instances of {@link SimpleChange}. See {@link OnChanges}
|
12
|
* @stable
|
13
|
*/
|
14
|
export interface SimpleChanges {
|
15
|
[propName: string]: SimpleChange;
|
16
|
}
|
17
|
/**
|
18
|
* @whatItDoes Lifecycle hook that is called when any data-bound property of a directive changes.
|
19
|
* @howToUse
|
20
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'}
|
21
|
*
|
22
|
* @description
|
23
|
* `ngOnChanges` is called right after the data-bound properties have been checked and before view
|
24
|
* and content children are checked if at least one of them has changed.
|
25
|
* The `changes` parameter contains the changed properties.
|
26
|
*
|
27
|
* See {@linkDocs guide/lifecycle-hooks#onchanges "Lifecycle Hooks Guide"}.
|
28
|
*
|
29
|
* @stable
|
30
|
*/
|
31
|
export interface OnChanges {
|
32
|
ngOnChanges(changes: SimpleChanges): void;
|
33
|
}
|
34
|
/**
|
35
|
* @whatItDoes Lifecycle hook that is called after data-bound properties of a directive are
|
36
|
* initialized.
|
37
|
* @howToUse
|
38
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnInit'}
|
39
|
*
|
40
|
* @description
|
41
|
* `ngOnInit` is called right after the directive's data-bound properties have been checked for the
|
42
|
* first time, and before any of its children have been checked. It is invoked only once when the
|
43
|
* directive is instantiated.
|
44
|
*
|
45
|
* See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
|
46
|
*
|
47
|
* @stable
|
48
|
*/
|
49
|
export interface OnInit {
|
50
|
ngOnInit(): void;
|
51
|
}
|
52
|
/**
|
53
|
* @whatItDoes Lifecycle hook that is called when Angular dirty checks a directive.
|
54
|
* @howToUse
|
55
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
|
56
|
*
|
57
|
* @description
|
58
|
* `ngDoCheck` gets called to check the changes in the directives in addition to the default
|
59
|
* algorithm. The default change detection algorithm looks for differences by comparing
|
60
|
* bound-property values by reference across change detection runs.
|
61
|
*
|
62
|
* Note that a directive typically should not use both `DoCheck` and {@link OnChanges} to respond to
|
63
|
* changes on the same input, as `ngOnChanges` will continue to be called when the default change
|
64
|
* detector detects changes.
|
65
|
*
|
66
|
* See {@link KeyValueDiffers} and {@link IterableDiffers} for implementing custom dirty checking
|
67
|
* for collections.
|
68
|
*
|
69
|
* See {@linkDocs guide/lifecycle-hooks#docheck "Lifecycle Hooks Guide"}.
|
70
|
*
|
71
|
* @stable
|
72
|
*/
|
73
|
export interface DoCheck {
|
74
|
ngDoCheck(): void;
|
75
|
}
|
76
|
/**
|
77
|
* @whatItDoes Lifecycle hook that is called when a directive, pipe or service is destroyed.
|
78
|
* @howToUse
|
79
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
|
80
|
*
|
81
|
* @description
|
82
|
* `ngOnDestroy` callback is typically used for any custom cleanup that needs to occur when the
|
83
|
* instance is destroyed.
|
84
|
*
|
85
|
* See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
|
86
|
*
|
87
|
* @stable
|
88
|
*/
|
89
|
export interface OnDestroy {
|
90
|
ngOnDestroy(): void;
|
91
|
}
|
92
|
/**
|
93
|
*
|
94
|
* @whatItDoes Lifecycle hook that is called after a directive's content has been fully
|
95
|
* initialized.
|
96
|
* @howToUse
|
97
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'}
|
98
|
*
|
99
|
* @description
|
100
|
* See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
|
101
|
*
|
102
|
* @stable
|
103
|
*/
|
104
|
export interface AfterContentInit {
|
105
|
ngAfterContentInit(): void;
|
106
|
}
|
107
|
/**
|
108
|
* @whatItDoes Lifecycle hook that is called after every check of a directive's content.
|
109
|
* @howToUse
|
110
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'}
|
111
|
*
|
112
|
* @description
|
113
|
* See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
|
114
|
*
|
115
|
* @stable
|
116
|
*/
|
117
|
export interface AfterContentChecked {
|
118
|
ngAfterContentChecked(): void;
|
119
|
}
|
120
|
/**
|
121
|
* @whatItDoes Lifecycle hook that is called after a component's view has been fully
|
122
|
* initialized.
|
123
|
* @howToUse
|
124
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'}
|
125
|
*
|
126
|
* @description
|
127
|
* See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
|
128
|
*
|
129
|
* @stable
|
130
|
*/
|
131
|
export interface AfterViewInit {
|
132
|
ngAfterViewInit(): void;
|
133
|
}
|
134
|
/**
|
135
|
* @whatItDoes Lifecycle hook that is called after every check of a component's view.
|
136
|
* @howToUse
|
137
|
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'}
|
138
|
*
|
139
|
* @description
|
140
|
* See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
|
141
|
*
|
142
|
* @stable
|
143
|
*/
|
144
|
export interface AfterViewChecked {
|
145
|
ngAfterViewChecked(): void;
|
146
|
}
|