Add make helper and bump version
This commit is contained in:
@@ -37,6 +37,8 @@ export * from './http/lifecycle/Request'
|
||||
export * from './http/lifecycle/Response'
|
||||
export * from './http/RequestLocalStorage'
|
||||
|
||||
export * from './make'
|
||||
|
||||
export * as api from './http/response/api'
|
||||
export * from './http/response/DehydratedStateResponseFactory'
|
||||
export * from './http/response/ErrorResponseFactory'
|
||||
|
||||
13
src/make.ts
Normal file
13
src/make.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {TypedDependencyKey} from './di'
|
||||
import {Application} from './lifecycle/Application'
|
||||
import {RequestLocalStorage} from './http/RequestLocalStorage'
|
||||
|
||||
export function make<T>(key: TypedDependencyKey<T>): T {
|
||||
const container = Application.getApplication()
|
||||
const rls = container.make<RequestLocalStorage>(RequestLocalStorage)
|
||||
if ( rls.has() ) {
|
||||
return rls.get().make(key)
|
||||
}
|
||||
|
||||
return container.make(key)
|
||||
}
|
||||
Reference in New Issue
Block a user