Add generic session interfaces; memory session; factories; kernel
This commit is contained in:
@@ -146,7 +146,7 @@ class Container {
|
||||
make(target: DependencyKey, ...parameters: any[]) {
|
||||
if ( this.has_key(target) )
|
||||
return this.resolve_and_create(target, ...parameters)
|
||||
else if ( typeof target !== 'string' )
|
||||
else if ( typeof target !== 'string' && isInstantiable(target) )
|
||||
return this.produce_factory(new Factory(target), parameters)
|
||||
else
|
||||
throw new TypeError(`Invalid or unknown make target: ${target}`)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Instantiable from './Instantiable.ts'
|
||||
import {StaticClass} from './StaticClass.ts'
|
||||
const DEPENDENCY_KEYS_METADATA_KEY = 'daton:di:dependencyKeys.ts'
|
||||
type DependencyKey = Instantiable<any> | string
|
||||
type DependencyKey = Instantiable<any> | StaticClass<any> | string
|
||||
export { DependencyKey, DEPENDENCY_KEYS_METADATA_KEY }
|
||||
|
||||
5
di/src/type/StaticClass.ts
Normal file
5
di/src/type/StaticClass.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export type StaticClass<T> = Function & {prototype: T}
|
||||
|
||||
export function isStaticClass<T>(something: any): something is StaticClass<T> {
|
||||
return typeof something === 'function' && typeof something.prototype !== 'undefined'
|
||||
}
|
||||
Reference in New Issue
Block a user