Function createAsyncFactory

  • Creates an async factory for a class such that its _init method is called and awaited before the instantiated object is returned.

    Parameters

    • cls: any

    Returns ((...args) => Promise<any>)

      • (...args): Promise<any>
      • Parameters

        • Rest ...args: any[]

        Returns Promise<any>

    Example

    class Api {
    constructor(foo, bar) { ... }

    async _init() {
    await some_initialization_logic();
    }

    ...
    }

    export const create_api = create_async_factory(Api);

Generated using TypeDoc