forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstants.ts
85 lines (75 loc) · 2.38 KB
/
constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* The strategy that the default change detector uses to detect changes.
* When set, takes effect the next time change detection is triggered.
*
* @publicApi
*/
export enum ChangeDetectionStrategy {
/**
* Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated
* until reactivated by setting the strategy to `Default` (`CheckAlways`).
* Change detection can still be explicitly invoked.
* This strategy applies to all child directives and cannot be overridden.
*/
OnPush = 0,
/**
* Use the default `CheckAlways` strategy, in which change detection is automatic until
* explicitly deactivated.
*/
Default = 1,
}
/**
* Defines the possible states of the default change detector.
* @see `ChangeDetectorRef`
*/
export enum ChangeDetectorStatus {
/**
* A state in which, after calling `detectChanges()`, the change detector
* state becomes `Checked`, and must be explicitly invoked or reactivated.
*/
CheckOnce,
/**
* A state in which change detection is skipped until the change detector mode
* becomes `CheckOnce`.
*/
Checked,
/**
* A state in which change detection continues automatically until explicitly
* deactivated.
*/
CheckAlways,
/**
* A state in which a change detector sub tree is not a part of the main tree and
* should be skipped.
*/
Detached,
/**
* Indicates that the change detector encountered an error checking a binding
* or calling a directive lifecycle method and is now in an inconsistent state. Change
* detectors in this state do not detect changes.
*/
Errored,
/**
* Indicates that the change detector has been destroyed.
*/
Destroyed,
}
/**
* Reports whether a given strategy is currently the default for change detection.
* @param changeDetectionStrategy The strategy to check.
* @returns True if the given strategy is the current default, false otherwise.
* @see `ChangeDetectorStatus`
* @see `ChangeDetectorRef`
*/
export function isDefaultChangeDetectionStrategy(changeDetectionStrategy: ChangeDetectionStrategy):
boolean {
return changeDetectionStrategy == null ||
changeDetectionStrategy === ChangeDetectionStrategy.Default;
}