Skip to content

Async factories #30

@schiller-manuel

Description

@schiller-manuel

Did you consider adding support for async factories?

This is how an async factory might be used:

class Server {
    public async init() {
    }
}

async function serverFactory() {
    const server = new Server();
    await server.init();
    return server;
}

class App {
    public static inject = ['server'];
    constructor(private server: Server) {
        // server is already initialized
   }
}

const injector = createInjector().provideFactory('server', serverFactory);
const app = await injector.injectClass(App);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions