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

app.addSingleton 加异步支持 #2246

Closed
XadillaX opened this issue Mar 20, 2018 · 6 comments
Closed

app.addSingleton 加异步支持 #2246

XadillaX opened this issue Mar 20, 2018 · 6 comments

Comments

@XadillaX
Copy link
Member

XadillaX commented Mar 20, 2018

  • Node Version: -
  • Egg Version: 2.x
  • Plugin Name: -
  • Plugin Version: -
  • Platform: -
  • Mini Showcase Repository:
     app.addSingleton(async (...) => {
       // 从远端获取一些配置
       const conf = await foo.fetch(...);
    
       return new Instance(conf);
     });

是否能为 app.addSingleton() 增加异步(async)支持?

@popomore
Copy link
Member

这个 @dead-horse 看看,内部 mysql 遇到这个问题

@popomore
Copy link
Member

popomore commented Mar 25, 2018

之前也有个 #841

@popomore
Copy link
Member

popomore commented Apr 9, 2018

可以两个维度,在 config 那根据 client 配一个方法,可以让用户动态获取配置。在 handler 也支持 async,让插件也可以自己动态查询配置,比如我们自己就是要从 keycenter 取

@popomore
Copy link
Member

popomore commented Apr 9, 2018

#2353 (comment)

@cuyl
Copy link
Contributor

cuyl commented Apr 13, 2018

还是希望app.addSingleton能添加async支持,这样的话我就能直接把异步获取的对象直接挂在app下,而不是在外面封装一层

@atian25 atian25 closed this as completed Apr 18, 2018
@XadillaX
Copy link
Member Author

XadillaX commented May 4, 2018

#2382

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