You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncinit(){constoptions=this.options;assert(!(options.client&&options.clients),`eggg:singleton ${this.name} can not set options.client and options.clients both`);// alias app[name] as client, but still support createInstance methodif(options.client){constclient=awaitthis.createInstance(options.client);// awaitthis.app[this.name]=client;assert(!client.createInstance,'singleton instance should not have createInstance method');client.createInstance=this.createInstance.bind(this);return;}// multi clent, use app[name].getInstance(id)if(options.clients){for(constidinoptions.clients){this.clients.set(id,awaitthis.createInstance(options.clients[id]));// await}this.app[this.name]=this;return;}// no config.clients and config.clientthis.app[this.name]=this;}
请问这个init函数能否改成async函数,如果不行是否有别的解决方案。
谢谢
The text was updated successfully, but these errors were encountered:
你好:
我想写个oracledb的插件,但是想给addSingleton传一个async函数,因为async function返回的是promise,所以如下的代码获取到的app.oracle就是一个Promise。
我找到了源代码,发现我传入的函数在
singleton.init()
中执行暂时我只能把这个init函数改成async函数来解决问题
lib/core/singleton.js#L19
请问这个init函数能否改成async函数,如果不行是否有别的解决方案。
谢谢
The text was updated successfully, but these errors were encountered: