@ -6,16 +6,27 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {unimplemented} from '../facade/exceptions';
|
||||
import {BaseException, unimplemented} from '../facade/exceptions';
|
||||
import {stringify} from '../facade/lang';
|
||||
|
||||
const _THROW_IF_NOT_FOUND = /*@ts2dart_const*/ new Object();
|
||||
export const THROW_IF_NOT_FOUND = /*@ts2dart_const*/ _THROW_IF_NOT_FOUND;
|
||||
|
||||
class _NullInjector implements Injector {
|
||||
get(token: any, notFoundValue: any = _THROW_IF_NOT_FOUND): any {
|
||||
if (notFoundValue === _THROW_IF_NOT_FOUND) {
|
||||
throw new BaseException(`No provider for ${stringify(token)}!`);
|
||||
}
|
||||
return notFoundValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @stable
|
||||
*/
|
||||
export abstract class Injector {
|
||||
static THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
||||
static NULL: Injector = new _NullInjector();
|
||||
|
||||
/**
|
||||
* Retrieves an instance from the injector based on the provided token.
|
||||
|
Reference in New Issue
Block a user