Interface IResource<TConfig, TValue, TDependencies, TContext>

interface IResource<TConfig, TValue, TDependencies, TContext> {
    [symbolFilePath]?: string;
    [symbolIndexResource]?: boolean;
    context?: (() => TContext);
    dependencies?: TDependencies | ((config: TConfig) => TDependencies);
    dispose?: ((this: any, value: TValue, config: TConfig, dependencies: DependencyValuesType<TDependencies>, context: TContext) => Promise<void>);
    events: {
        afterInit: IEvent<AfterInitEventPayload<TConfig, TValue>>;
        beforeInit: IEvent<BeforeInitEventPayload<TConfig>>;
        onError: IEvent<OnErrorEventPayload>;
    };
    id: string | symbol;
    init?: ((this: any, config: TConfig, dependencies: DependencyValuesType<TDependencies>, context: TContext) => Promise<TValue>);
    meta?: IResourceMeta;
    middleware: MiddlewareAttachments[];
    overrides: (
        | IMiddleware<any, any>
        | IResource<void, any, any, any>
        | ITask<any, any, {}, undefined>
        | IResourceWithConfig<any, any, any>)[];
    register: RegisterableItems<any>[] | ((config: TConfig) => RegisterableItems<any>[]);
    with(config: TConfig): IResourceWithConfig<TConfig, TValue, TDependencies>;
}

Type Parameters

  • TConfig = void
  • TValue = any
  • TDependencies extends DependencyMapType = any
  • TContext = any

Hierarchy (view full)

Properties

[symbolFilePath]?: string

This is optional and used from an index resource to get the correct caller.

[symbolIndexResource]?: boolean

This is used internally when creating index resources.

context?: (() => TContext)
dependencies?: TDependencies | ((config: TConfig) => TDependencies)
dispose?: ((this: any, value: TValue, config: TConfig, dependencies: DependencyValuesType<TDependencies>, context: TContext) => Promise<void>)

Clean-up function for the resource. This is called when the resource is no longer needed.

Type declaration

    • (this, value, config, dependencies, context): Promise<void>
    • Parameters

      Returns Promise<void>

      Promise

events: {
    afterInit: IEvent<AfterInitEventPayload<TConfig, TValue>>;
    beforeInit: IEvent<BeforeInitEventPayload<TConfig>>;
    onError: IEvent<OnErrorEventPayload>;
}

These events are automatically populated after the task has been defined.

id: string | symbol
init?: ((this: any, config: TConfig, dependencies: DependencyValuesType<TDependencies>, context: TContext) => Promise<TValue>)
middleware: MiddlewareAttachments[]
overrides: (
    | IMiddleware<any, any>
    | IResource<void, any, any, any>
    | ITask<any, any, {}, undefined>
    | IResourceWithConfig<any, any, any>)[]
register: RegisterableItems<any>[] | ((config: TConfig) => RegisterableItems<any>[])

Methods