Closed leiyangyou closed 4 months ago
mixins started invocation order is in reverse
I expect that mixin invocation order is in order of inclusion
Please provide detailed steps for reproducing the issue.
env SERVICES=exps yarn start
module.exports = { name: 'exps', mixins: [ { started () { console.log('queue service started') }, stopped () { console.log('queue service stopped') } }, { started () { console.log('db service started') }, stopped () { console.log('db service stopped') } } ], actions: { test (ctx) { console.log(ctx.logger) } }, started () { console.log('exps service started', this.settings) }, stopped () { console.log('exps service stopped') } }
the above code prints db service started then queue service started
is there any particular reason why mixin inclusions are in reverse order of definition?
the relevant lines are in service.js, why do we reverse()?
const mixedSchema = Array.from(mixins) .reverse() .reduce((s, mixin) => { if (mixin.mixins) mixin = this.applyMixins(mixin); return s ? this.mergeSchemas(s, mixin) : mixin; }, null);
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Current Behavior
mixins started invocation order is in reverse
Expected Behavior
I expect that mixin invocation order is in order of inclusion
Failure Information
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
env SERVICES=exps yarn start
Reproduce code snippet
the above code prints db service started then queue service started
is there any particular reason why mixin inclusions are in reverse order of definition?
the relevant lines are in service.js, why do we reverse()?
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.