We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我正在开发一个消息队列封装的插件,遇到了如下问题:
// {plugin}/app.ts module.exports = (app: Application) => { const consumerDir = path.join(app.baseDir, 'app/consumer'); app.loader.loadToApp(consumerDir, 'consumer', { caseStyle: 'upper', initializer(factory: new (ctx: Context, redis: Redis, options: ConsumerOptions) => Consumer) { const ctx = app.createAnonymousContext(); return new factory(ctx, app.redis, app.config.consumer[factory.name]); }, }); };
// {plugin}/config/config.default.ts export default () => { const config = {} as PowerPartial<EggAppConfig>; config.customLoader = { producer: { directory: 'app/producer', inject: 'app', caseStyle: 'upper', initializer(factory: typeof Producer) { // 我应当用什么方式获取 app 呢? const ctx = app.createAnonymousContext(); return new factory(ctx, app.redis, app.config.producer[factory.name]); }, }, }; return config; };
我查看了部分源码,发现此处如果 inject.length !== 0 就不会向 config.default.ts 中注入 app 对象了。
inject.length !== 0
config.default.ts
请问我是有其他方式在 config.default.ts 中拿到 app 呢,还是可以在 app.ts 中通过一些 api 提供 ts 类型提示呢?
app.ts
The text was updated successfully, but these errors were encountered:
可以参考 https://github.com/eggjs/egg-schedule ,封装一个 mq 的 Subscription 编程界面
Sorry, something went wrong.
No branches or pull requests
请详细告知你的新点子(Nice Ideas):
我正在开发一个消息队列封装的插件,遇到了如下问题:
我查看了部分源码,发现此处如果
inject.length !== 0
就不会向config.default.ts
中注入 app 对象了。请问我是有其他方式在
config.default.ts
中拿到 app 呢,还是可以在app.ts
中通过一些 api 提供 ts 类型提示呢?The text was updated successfully, but these errors were encountered: