Skip to content
Bunshi
GitHub

createInjector

createInjector(injectorProps = {}): MoleculeInjector

Creates a MoleculeInjector

This is the core stateful component of bunshi and can have interfaces bound to implementations here.

Parameters

ParameterType
injectorPropsCreateInjectorProps

Returns

MoleculeInjector

Source

src/vanilla/injector.ts:176

Example

Create an injector with bindings

const NumberMolecule = moleculeInterface<number>();
const RandomNumberMolecule = molecule<number>(()=>Math.random());

const injector = createInjector({
    bindings:[[NumberMolecule,RandomNumberMolecule]]
})