fnDI.js
Simple, functional, ligthweight, dependencyless DI/IOC library for JS
Usage
Install using yarn or npm
yarn add fndi npm install fndi
Getting started
// Function sintaxconst scope = ; {} // Class Sintax { thisa = a; } // Registration Functionconst registration = { ; ;}; { const bInstance = ;} const scopedMain = ; ;
Register
The registration is done within a function that takes a registry
function as
argument.
const registration = { //Only type registry ; // Named Registry ; // Provide a single instance every time ; // Registering a Factory function ; // Delegate the class };
Registry Entry
Each registry entry (the argument for the registry
function) must follow the
following definition:
Scopes
scope
is a function wrapper, it provides a resolve
function which can be
used in the underlying function to get instances of the defined types (by either
type or name).
{ const fooInstance = ; const barInstance = ;} const scopedMain = ; ;
TODO
- async dependencies
- Lazy dependencies