2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2015-05-01 17:05:19 -04:00
|
|
|
|
2015-12-03 18:49:09 -05:00
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* The strategy that the default change detector uses to detect changes.
|
|
|
|
* When set, takes effect the next time change detection is triggered.
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2015-12-03 18:49:09 -05:00
|
|
|
*/
|
2016-06-27 23:00:30 -04:00
|
|
|
export enum ChangeDetectionStrategy {
|
2015-10-27 13:55:01 -04:00
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* 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 explictly invoked.
|
2015-10-27 13:55:01 -04:00
|
|
|
*/
|
2017-08-16 12:00:03 -04:00
|
|
|
OnPush = 0,
|
2015-10-27 13:55:01 -04:00
|
|
|
|
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* Use the default `CheckAlways` strategy, in which change detection is automatic until
|
|
|
|
* explicitly deactivated.
|
2015-10-27 13:55:01 -04:00
|
|
|
*/
|
2017-08-16 12:00:03 -04:00
|
|
|
Default = 1,
|
2015-10-27 13:55:01 -04:00
|
|
|
}
|
|
|
|
|
2015-12-03 18:49:09 -05:00
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* Defines the possible states of the default change detector.
|
|
|
|
* @see `ChangeDetectorRef`
|
2015-12-03 18:49:09 -05:00
|
|
|
*/
|
2016-06-27 23:00:30 -04:00
|
|
|
export enum ChangeDetectorStatus {
|
2015-08-26 14:44:59 -04:00
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* A state in which, after calling `detectChanges()`, the change detector
|
|
|
|
* state becomes `Checked`, and must be explicitly invoked or reactivated.
|
2015-08-26 14:44:59 -04:00
|
|
|
*/
|
|
|
|
CheckOnce,
|
|
|
|
|
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* A state in which change detection is skipped until the change detector mode
|
|
|
|
* becomes `CheckOnce`.
|
2015-08-26 14:44:59 -04:00
|
|
|
*/
|
|
|
|
Checked,
|
|
|
|
|
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* A state in which change detection continues automatically until explictly
|
|
|
|
* deactivated.
|
2015-08-26 14:44:59 -04:00
|
|
|
*/
|
|
|
|
CheckAlways,
|
|
|
|
|
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* A state in which a change detector sub tree is not a part of the main tree and
|
2015-08-26 14:44:59 -04:00
|
|
|
* should be skipped.
|
|
|
|
*/
|
|
|
|
Detached,
|
|
|
|
|
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* Indicates that the change detector encountered an error checking a binding
|
2016-06-27 23:00:30 -04:00
|
|
|
* or calling a directive lifecycle method and is now in an inconsistent state. Change
|
2018-07-02 15:06:52 -04:00
|
|
|
* detectors in this state do not detect changes.
|
2015-08-26 14:44:59 -04:00
|
|
|
*/
|
2016-06-27 23:00:30 -04:00
|
|
|
Errored,
|
2015-08-26 14:44:59 -04:00
|
|
|
|
|
|
|
/**
|
2018-07-02 15:06:52 -04:00
|
|
|
* Indicates that the change detector has been destroyed.
|
2015-08-26 14:44:59 -04:00
|
|
|
*/
|
2016-06-27 23:00:30 -04:00
|
|
|
Destroyed,
|
2015-08-21 17:45:38 -04:00
|
|
|
}
|
|
|
|
|
2018-07-02 15:06:52 -04:00
|
|
|
/**
|
|
|
|
* 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`
|
|
|
|
*/
|
2016-06-08 19:38:52 -04:00
|
|
|
export function isDefaultChangeDetectionStrategy(changeDetectionStrategy: ChangeDetectionStrategy):
|
|
|
|
boolean {
|
2017-03-02 12:37:01 -05:00
|
|
|
return changeDetectionStrategy == null ||
|
2016-06-08 19:38:52 -04:00
|
|
|
changeDetectionStrategy === ChangeDetectionStrategy.Default;
|
2015-08-26 14:44:59 -04:00
|
|
|
}
|