@loopback/context
Version:
Facilities to manage artifacts and their dependencies in your Node.js applications. The module exposes TypeScript/JavaScript APIs and decorators to register artifacts, declare dependencies, and resolve artifacts by keys. It also serves as an IoC container
46 lines (45 loc) • 1.34 kB
TypeScript
import { BindingSpec } from './binding-inspector';
import { Constructor } from './value-promise';
/**
* Decorate a class with binding configuration
*
* @example
* ```ts
* @injectable((binding) => {binding.inScope(BindingScope.SINGLETON).tag('controller')}
* )
* @injectable({scope: BindingScope.SINGLETON})
* export class MyController {
* }
* ```
*
* @param specs - A list of binding scope/tags or template functions to
* configure the binding
*/
export declare function injectable(...specs: BindingSpec[]): ClassDecorator;
/**
* A namespace to host shortcuts for `@injectable`
*/
export declare namespace injectable {
/**
* `@injectable.provider` to denote a provider class
*
* A list of binding scope/tags or template functions to configure the binding
*/
function provider(...specs: BindingSpec[]): (target: Constructor<unknown>) => void;
}
/**
* `@bind` is now an alias to {@link injectable} for backward compatibility
* {@inheritDoc injectable}
*/
export declare function bind(...specs: BindingSpec[]): ClassDecorator;
/**
* Alias namespace `bind` to `injectable` for backward compatibility
*
* It should have the same members as `bind`.
*/
export declare namespace bind {
/**
* {@inheritDoc injectable.provider}
*/
const provider: typeof injectable.provider;
}