Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for asynchronous resolving for DI #1611

Open
brandonseydel opened this issue Oct 26, 2022 · 0 comments
Open

Allow for asynchronous resolving for DI #1611

brandonseydel opened this issue Oct 26, 2022 · 0 comments
Labels
Topic: Lifecycle Issues related to lifecycle hooks

Comments

@brandonseydel
Copy link
Member

馃檵 Feature Request

Would like to resolve DI async

馃 Expected Behavior

Resolves to the correct instance

馃槸 Current Behavior

Have to await it myself

Repro link https://stackblitz.com/edit/au2-conventions?file=src%2Fmy-app.html

馃拋 Possible Solution

Await it internally always

馃敠 Context

This will help people easily chunk their code

馃捇 Examples

 Registration.cachedCallback(IEncryptionClient, async () => {
      const LitJsSdk = (await import('lit-js-sdk')).default;
      const client: Partial<IEncryptionClient> = new LitJsSdk.LitNodeClient();
      client.getAuthSig = LitJsSdk.signAndSaveAuthMessage;
      client.encryptString = LitJsSdk.encryptString;
      client.decryptString = LitJsSdk.decryptString;
      client.uint8arrayToString = LitJsSdk.uint8arrayToString;
      return client as IEncryptionClient;
    }),
 private async connect(): Promise<void> {
    if (this.client) return;
//  i have to current await below but would like it to just resolve so I don't have to union type it
    const client = await this.container.get(IEncryptionClient);
    this.client = client;
    return await this.client.connect();
  }
@bigopon bigopon added the Topic: Lifecycle Issues related to lifecycle hooks label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic: Lifecycle Issues related to lifecycle hooks
Projects
None yet
Development

No branches or pull requests

2 participants