Injector
injector
holds application container it can be injected to any class
#
Usage#
API#
getget<T>(objectID: string | Function, runtimeArgs?: any[]): T
#
return object instance by id or class type if the instance not found error is throw
if the object is not singleton run time args can be passed to object instance
#
getAsyncgetAsync<T>(objectID: string | Function, runtimeArgs?: any[]): Promise<T>
#
same as get
return promise after the instance initAsyc method resolved
#
resolveresolve<T>(objectID: string | Function, runtimeArgs?: any[]): T
#
same as get
but if the instance not found null
is returned
#
getInstancegetInstance<T>(id: string): T
#
get singleton instance by id if not found null
is returned
#
hasInstancehasInstance(id: string): boolean
#
return true if singleton instance exists
#
addInstanceaddInstance(instanceId: string, instance: any): Injector
#
add instance by instance id
#
removeInstanceremoveInstance(objectId: string): Injector
#
remove instance by id
#
getObjectsByTypegetObjectsByType<T>(type: Function): T[]
#
return array of matched objects by type
#
getInstancesgetInstances(): { [id: string]: { [index: string]: any } }
#
get all instances index by id
#
getDefinitionsgetDefinitions(): { [id: string]: IDefinition }
#
get all definitions index by id
#
getDefinitionsValuegetDefinitionsValue(): IDefinition[]
#
get all definitions array
#
getTypes#
getTypes(): Function[]get all Classes
#
hasDefinitionhasDefinition(id: string): boolean
#
return true if definition exists
#
getDefinitiongetDefinition(id: string): IDefinition
#
get definition by id
#
addDefinitionaddDefinition(objectId: string, definition: IDefinition): Injector
#
add definition by id
#
addAliasaddAlias(aliasName: string, value: any)
#
add alias by alias name
#
removeAliasremoveAlias(aliasName: string, value: any)
#
remove alias by name and value
#
getAliasgetAlias(aliasName: string): any[]
#
get all instances by alias name
#
addAliasFactoryaddAliasFactory(aliasName: string, value: any)
#
add alias by alias name
#
removeAliasFactoryremoveAliasFactory(aliasName: string, value: any)
#
remove alias by name and value
#
getAliasFactorygetAliasFactory(aliasName: string): any[]
#
get all instances by alias name
#
getFactoryMethodgetFactoryMethod(objectId: string | Function)
#
return factory create method by id
#
registerregister(id: string | Class, type?: Class, filePath?: string): Define
#
register new definition