feat(ivy): support injection even if no injector present (#23345)

- Remove default injection value from `inject` / `directiveInject` since
  it is not possible to set using annotations.
- Module `Injector` is stored on `LView` instead of `LInjector` data
  structure because it can change only at `LView` level. (More efficient)
- Add `ngInjectableDef` to `IterableDiffers` so that existing tests can
  pass as well as enable `IterableDiffers` to be injectable without
  `Injector`

PR Close #23345
This commit is contained in:
Misko Hevery
2018-04-12 15:54:16 -07:00
committed by Igor Minar
parent 6f213a74f2
commit da31db757b
21 changed files with 175 additions and 105 deletions

View File

@ -242,7 +242,7 @@ export declare class DefaultIterableDiffer<V> implements IterableDiffer<V>, Iter
/** @experimental */
export declare function defineInjectable<T>(opts: {
providedIn?: Type<any> | 'root' | null;
providedIn?: Type<any> | 'root' | 'any' | null;
factory: () => T;
}): InjectableDef<T>;
@ -336,9 +336,8 @@ export interface HostDecorator {
export declare const HostListener: HostListenerDecorator;
/** @experimental */
export declare function inject<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: undefined, flags?: InjectFlags): T;
export declare function inject<T>(token: Type<T> | InjectionToken<T>, notFoundValue: T, flags?: InjectFlags): T;
export declare function inject<T>(token: Type<T> | InjectionToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
export declare function inject<T>(token: Type<T> | InjectionToken<T>): T;
export declare function inject<T>(token: Type<T> | InjectionToken<T>, flags?: InjectFlags): T | null;
export declare const Inject: InjectDecorator;
@ -359,6 +358,7 @@ export interface InjectableDecorator {
export interface InjectableDef<T> {
factory: () => T;
providedIn: InjectorType<any> | 'root' | 'any' | null;
value: T | undefined;
}
/** @experimental */
@ -462,6 +462,7 @@ export declare class IterableDiffers {
/** @deprecated */ factories: IterableDifferFactory[];
constructor(factories: IterableDifferFactory[]);
find(iterable: any): IterableDifferFactory;
static ngInjectableDef: InjectableDef<IterableDiffers>;
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
static extend(factories: IterableDifferFactory[]): StaticProvider;
}