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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插件的 addSingleton 的 async 函数问题 #841

Closed
Rwing opened this issue May 4, 2017 · 4 comments
Closed

插件的 addSingleton 的 async 函数问题 #841

Rwing opened this issue May 4, 2017 · 4 comments
Assignees

Comments

@Rwing
Copy link
Contributor

Rwing commented May 4, 2017

假设我的插件需要 promise 的来返回一个实例,貌似现在 addSingleton 是不支持的,请问我要怎么解决?

module.exports = app => {
  app.addSingleton('mysql', createMysql);
}

async function createMysql(config, app) {
  //...
  return await getClient();
}
@dead-horse dead-horse self-assigned this May 4, 2017
@dead-horse
Copy link
Member

我考虑一下吧

@cuyl
Copy link
Contributor

cuyl commented May 6, 2017

#710
我之前也提了一个类似的问题,要是能支持async的就太好了

@Rwing
Copy link
Contributor Author

Rwing commented May 7, 2017

@cuyl 谢谢,我先用你这个 issue 里提到的解决翻案吧

@atian25
Copy link
Member

atian25 commented Apr 18, 2018

#2392

@atian25 atian25 closed this as completed Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants