pumpit
- AvailableScopes
- AvailableTypes
- BindKey
- ClassOptions
- ClassValue
- FactoryOptions
- FactoryValue
- ResolveCtx
Ƭ AvailableScopes: keyof typeof SCOPE
Available scopes that can be used
Ƭ AvailableTypes: keyof typeof TYPE
Available types that can be binded
Ƭ BindKey: string
| symbol
| Record
<string
, any
>
Type of values that can be used for the bind key
Ƭ ClassOptions<T
, K
>: Object
Class bind options
Name | Type |
---|---|
T |
extends ClassValue |
K |
extends AvailableScopes = "TRANSIENT" |
Name | Type | Description |
---|---|---|
afterResolve? |
(data : { container : PumpIt ; ctx? : ResolveCtx ; value : any }) => void |
callback that is called after the value is resolved, number of calls depends on scope used when registering |
beforeResolve? |
(data : { container : PumpIt ; ctx? : ResolveCtx ; value : T extends (...args : any []) => any ? (...args : ConstructorParameters <T >) => T : (...args : ConstructorParameters <T ["value" ]>) => T ["value" ] }, ...deps : T extends (...args : any []) => any ? ConstructorParameters <T > : ConstructorParameters <T ["value" ]>) => any |
callback that is called before the value is resolved, number of calls depends on scope used when registering |
scope |
K |
Scope that is going to be used AvailableScopes |
type |
typeof CLASS |
Class constant type AvailableTypes |
unbind? |
(data : { container : PumpIt ; dispose : boolean ; value : K extends "SINGLETON" ? any : undefined }) => void |
callback that is called before the value is removed from the container. This is only executed for values that are SINGLETONS |
Ƭ ClassValue: (...args
: any
[]) => any
| { inject
: InjectionData
; value
: (...args
: any
[]) => any
}
Ƭ FactoryOptions<T
, K
>: Object
Name | Type |
---|---|
T |
extends FactoryValue |
K |
extends AvailableScopes |
Name | Type | Description |
---|---|---|
afterResolve? |
(data : { container : PumpIt ; ctx? : ResolveCtx ; value : any }) => void |
callback that is called after the value is resolved, number of calls depends on scope used when registering |
beforeResolve? |
(data : { container : PumpIt ; ctx? : ResolveCtx ; value : T extends (...args : any []) => any ? T : T ["value" ] }, ...deps : T extends (...args : any []) => any ? Parameters <T > : Parameters <T ["value" ]>) => any |
callback that is called before the value is resolved, number of calls depends on scope used when registering |
scope |
K |
Scope that is going to be used AvailableScopes |
type |
typeof FACTORY |
Factory constant type |
unbind? |
(data : { container : PumpIt ; dispose : boolean ; value : K extends "SINGLETON" ? any : undefined }) => void |
callback that is called before the value is removed from the container. This is only executed for values that are SINGLETONS |
Ƭ FactoryValue: (...args
: any
[]) => any
| { inject
: InjectionData
; value
: (...args
: any
[]) => any
}
Ƭ ResolveCtx: Record
<string
, any
>
Resolve context that is used per request and passed to the callbacks
• Const
SCOPE: Object
Constants that represent the type of scopes that can be used SINGLETON - value is resolved only once TRANSIENT - value is resolved everytime it is requested REQUEST - value is resolved once per request PumpIt.resolve() CONTAINER_SINGLETON - the child container will create it's own version of the singleton instance
Name | Type |
---|---|
CONTAINER_SINGLETON |
"CONTAINER_SINGLETON" |
REQUEST |
"REQUEST" |
SINGLETON |
"SINGLETON" |
TRANSIENT |
"TRANSIENT" |
• Const
TYPE: Object
Constants that represent the type of values that can be binded
Name | Type |
---|---|
CLASS |
"CLASS" |
FACTORY |
"FACTORY" |
VALUE |
"VALUE" |
▸ get(key
, options?
): () => { key
: BindKey
; options
: { optional?
: boolean
} }
get dependency by key
Name | Type | Description |
---|---|---|
key |
BindKey |
dependency BindKey |
options? |
Object |
options for the resove process |
options.optional? |
boolean |
if the dependency cannot be resolved undefined will be used |
fn
▸ (): Object
Object
Name | Type |
---|---|
key |
BindKey |
options |
{ optional? : boolean } |
options.optional? |
boolean |
Name | Type |
---|---|
[INJECTION_FN] |
typeof INJECTION_FN |
▸ transform(deps
, fn
): Object
Wrapper function for registering dependencies that can be manipulated before being injected It gets an array of dependencies in injection order, and it should return an array
Name | Type | Description |
---|---|---|
deps |
(BindKey | (key : BindKey , options? : { optional? : boolean }) => () => { key : BindKey ; options : { optional? : boolean } })[] |
array of dependencies that need to be satisfied see: BindKey get() |
fn |
(data : { container : PumpIt ; ctx : ResolveCtx }, ...deps : any []) => any [] |
function that will be called with the resolved dependencies |
Object
Name | Type |
---|---|
action |
symbol |
deps |
(BindKey | (key : BindKey , options? : { optional? : boolean }) => () => { key : BindKey ; options : { optional? : boolean } })[] |
fn |
(data : { container : PumpIt ; ctx : ResolveCtx }, ...deps : any []) => any [] |