define: Creates a key to factory binding

Description Usage Arguments Examples

Description

Creates a key to factory binding

Usage

1
define(..., scope = default, binder = .binder)

Arguments

...

injectable bean identifier to factory mappings, the key is the name is matched to a parameter name during injection, the factory responsible for provisioning of the bean, a factory may accept any number of arguments in which case the framework will attempt to inject the argument if a binding to the parameter name exists; if it does not, that argument will not be injected, in which case it is the factory's responsibility to deal with a missing argument

scope

of the bean, wraps the injected factory call specifying provisioning strategy, if omitted a new bean instance will be provisioned each time injection is requested; injectoR also ships with with the singleton scope which will provide once and cache the bean for subsequent calls. Interface allows for custom scoping, the scope parameter must be a function accepting key (name) and the provider - the wrapped injected factory call - a function accepting no parameters responsible for actual provisioning

binder

for this binding, if omitted the new binding is added to the root binder

Examples

1
define (hello = function () 'world', binder = binder ())

dfci-cccb/injectoR documentation built on May 15, 2019, 5:12 a.m.