UNPKG

@primno/core

Version:

Front-end framework for Model-Driven Apps of Power Apps and Dynamics 365.

44 lines (43 loc) 1.53 kB
import { Container as InvContainer } from "inversify"; import { ComponentConstructor } from "../../../typing/component"; import { Bind } from "./bind"; export interface Middleware { /** * If true, the middleware will be inherited by child containers. */ inherit: boolean; /** * Called before the construction of an instance. */ onPreConstruct(identifier: any, container: Container, key?: string | symbol | number): void; /** * Called after the construction of an instance. */ onPostConstruct(instance: unknown, container: Container): unknown; /** * Called when an error is thrown during the construction of an instance. */ onError(errorMsg: string): void; } /** * Container for dependency injection. */ export declare class Container { protected children: Container[]; protected invContainer: InvContainer; protected middleware: Middleware[]; constructor(parentContainer?: Container); /** * Middleware will be executed left to right. * @param middleware Middleware */ addMiddleware(...middleware: Middleware[]): void; bind(bind: Bind): void; bindComponent(componentType: ComponentConstructor): void; bindClass(provider: any, value: any): void; bindConstantValue(provider: any, value: any): void; bindDynamicValue(provider: any, dynValResolver: (target: any) => any): void; createChild(): Container; isBound(serviceIdentifier: any): boolean; get(serviceIdentifier: any): unknown; }