Skip to content

Commit

Permalink
Merge pull request #15 from dmihal/patch-1
Browse files Browse the repository at this point in the history
Don't pass the callback to the handler
  • Loading branch information
johanbrook authored Dec 23, 2016
2 parents d7881d6 + 1afc5fb commit f76e0d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions publication-collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ PublicationCollector = class PublicationCollector extends EventEmitter {
}

collect(name, ...args) {
const handler = Meteor.server.publish_handlers[name];
const result = handler.call(this, ...args);

if (_.isFunction(args[args.length - 1])) {
const callback = args.pop();
this.on('ready', collections => {
Expand All @@ -38,6 +35,9 @@ PublicationCollector = class PublicationCollector extends EventEmitter {
});
}

const handler = Meteor.server.publish_handlers[name];
const result = handler.call(this, ...args);

// TODO -- we should check that result has _publishCursor? What does _runHandler do?
if (result) {
// array-ize
Expand Down
12 changes: 12 additions & 0 deletions tests/publication-collector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ describe('PublicationCollector', () => {

collector.collect('publicationWithArgs', 'foo', 'bar');
});

it('should support optional publication arguments', (done) => {
Meteor.publish('publicationWithOptionalArg', function(arg1 = 'foo') {
assert.equal(arg1, 'foo');
this.ready();
done();
});

const collector = new PublicationCollector();

collector.collect('publicationWithOptionalArg', function(){});
});
});

describe('Added', () => {
Expand Down

0 comments on commit f76e0d9

Please sign in to comment.