b-ioc-js
Version:
A magic free, dirt simple IoC container for Javascript.
50 lines (49 loc) • 1.69 kB
text/typescript
/**
* IoC Module
* @module b-ioc-js
*/
export * from './types.js';
import type { Bindings, Factory, Singletons } from './types.js';
/**
* Gets all of the current bindings in the container
* @return {Bindings} The containers bindings
*/
export declare function getBindings(): Bindings;
/**
* Gets all of the current singletons in the container
* @return {Singletons} The containers singletons
*/
export declare function getSingletons(): Singletons;
/**
* Resets container to default state
*/
export declare function clear(): void;
/**
* Assigns to our bindings object
* @template T
* @param {String} binding The name of the IoC binding
* @param {Factory<T> | T} closure Factory method or value to bind to container
*/
export declare function bind<T>(binding: string, closure: Factory<T> | T): void;
/**
* Assigns to our singleton object
* @template T
* @param {String} binding The name of the IoC binding
* @param {Factory<T> | T} closure Factory method or value to bind to container
*/
export declare function singleton<T>(binding: string, closure: Factory<T> | T): void;
/**
* Grabs a binding from the IoC. Leverages node require as a fallback
* @template T
* @param {String} binding The name of the binding in the container
* @returns {T} The instance of the binding
*/
export declare function use<T>(binding: string): T;
/**
* Creates an instance of a class and will inject dependencies defined in static
* inject method. This is an alternative to using Ioc.bind
* @template T
* @param {T} Obj The class you wish to create a new instance of
* @return {T} The instantiated function instance
*/
export declare function make<T>(Obj: new () => T): T;