##// END OF EJS Templates
working on IoC configuration
working on IoC configuration

File last commit:

r112:efce7387bfc8 ioc ts support
r114:475b8ce3e850 ioc ts support
Show More
config.ts
68 lines | 1.3 KiB | video/mp2t | TypeScriptLexer
cin
dependency builder proposal
r110 import { Foo } from "./Foo";
import { Bar } from "./Bar";
import { ActivationType } from "../di/interfaces";
import { Builder } from "../di/Annotations";
import { Box } from "./Box";
interface RegistrationOptions {
activation?: ActivationType;
}
cin
Working on IoC container configuration
r111 interface Dependency<K extends keyof any> {
$dependency: K;
lazy?: boolean;
}
interface Lazy<K extends keyof any> extends Dependency<K> {
lazy: true;
}
type PromiseOrValue<T> = T | PromiseLike<T>;
cin
dependency builder proposal
r110 interface ConfigBuilder<S> {
cin
Working on IoC container configuration
r111 build<K extends keyof S, T = S[K]>(name: K): Builder<T, S>;
dependency<K extends keyof S>(name: K): Dependency<K>;
lazy<K extends keyof S>(name: K): Lazy<K>;
mapTo<K extends keyof S>(name: K, ctor: () => PromiseOrValue<new (...args: any[]) => S[K]>): ConfigBuilder<S>;
cin
dependency builder proposal
r110 }
interface ContainerServices {
barBox: Box<Bar>;
foo: Foo;
bar: Bar;
password: string;
user: string;
timeout: number;
}
cin
Working on IoC container configuration
r111 declare function load<M, C extends keyof M>(m: PromiseLike<M>, name: C): () => PromiseLike<M[C]>;
const t = {
barBox: load(import("./Box"), "Box"),
foo: async () => (await import("./Bar")).Bar,
bar: Bar,
password: String,
user: String,
timeout: Number
};
cin
Working on IoC container configuration
r112 declare const bc: typeof Box;
const x = new bc();
cin
dependency builder proposal
r110 export declare const config: ConfigBuilder<ContainerServices>;