Skip to content

Commit

Permalink
fix: corect meta merge
Browse files Browse the repository at this point in the history
  • Loading branch information
zetxx committed Feb 3, 2020
1 parent 884b046 commit c8914da
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ class Brid {
return this.findMethod({method, direction: false, channel: 'external', meta});
}

registerMethod({method, channel, fn, meta}) {
this.log('info', {in: 'base.registerMethod', description: `register method: ${channel}.${method}`, method, channel, meta});
callRegisteredMethod(fn, ctx, ...args) {
return fn.call(ctx, ...args);
}

registerMethod({method, channel, fn, meta: metaOld}) {
this.log('info', {in: 'base.registerMethod', description: `register method: ${channel}.${method}`, method, channel, meta: metaOld});
!this.apiMethods[channel] && (this.apiMethods[channel] = {});
this.apiMethods[channel][method] = async(ctx, ...args) => {
let [message, meta] = args;
this.log('trace', {in: 'base.registerMethod', description: `exec method: ${channel}.${method}`, message, meta});
return fn.call(ctx, ...args);
return this.callRegisteredMethod(fn, ctx, message, {...metaOld, ...meta, channel, method});
};
}

Expand Down

0 comments on commit c8914da

Please sign in to comment.