refactor(core): make lockRunMode a noop and deprecate it.

BREAKING CHANGE:
- `lockRunMode` is deprecated and no more needed.

Closes #9878
This commit is contained in:
Tobias Bosch
2016-07-07 14:42:46 -07:00
parent 1426f680f5
commit 98d49d4ce3
6 changed files with 29 additions and 43 deletions

View File

@ -64,30 +64,28 @@ export function enableProdMode(): void {
_devMode = false;
}
/**
* Returns whether Angular is in development mode.
* This can only be read after `lockRunMode` has been called.
*
* By default, this is true, unless a user calls `enableProdMode`.
*
* @experimental APIs related to application bootstrap are currently under review.
*/
export function isDevMode(): boolean {
if (!_runModeLocked) {
throw new BaseException(`Dev mode can't be read before bootstrap!`);
}
return _devMode;
}
/**
* Locks the run mode of Angular. After this has been called,
* it can't be changed any more. I.e. `isDevMode()` will always
* return the same value.
*
* @experimental APIs related to application bootstrap are currently under review.
* @deprecated This is a noop now. {@link isDevMode} automatically locks the run mode on first call.
*/
export function lockRunMode(): void {
console.warn('lockRunMode() is deprecated and not needed any more.');
}
/**
* Returns whether Angular is in development mode. After called once,
* the value is locked and won't change any more.
*
* By default, this is true, unless a user calls `enableProdMode` before calling this.
*
* @experimental APIs related to application bootstrap are currently under review.
*/
export function isDevMode(): boolean {
_runModeLocked = true;
return _devMode;
}
/**
@ -104,7 +102,6 @@ export function createPlatform(injector: Injector): PlatformRef {
throw new BaseException(
'There can be only one platform. Destroy the previous one to create a new one.');
}
lockRunMode();
_inPlatformCreate = true;
try {
_platform = injector.get(PlatformRef);