Registry
About
Implementing using Singleton
export default class Registry {
private dependencies: {[name: string]: any} = {};
private static instance: Registry;
private constructor() {}
provide(name: string, dependency: any) {
this.dependencies[name] = dependency;
}
inject(name: string) {
return this.dependencies[name];
}
static getInstance() {
if (!Registry.instance) Registry.instance = new Registry();
return Registry.instance;
}
}Example (without decorators)
decorators)This
Will be substituted by
Example (with decorators) (in typescript)
decorators) (in typescript)Last updated