Skip to content
New issue

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

Cancel publish #25

Closed
medihack opened this issue Jan 2, 2015 · 6 comments
Closed

Cancel publish #25

medihack opened this issue Jan 2, 2015 · 6 comments

Comments

@medihack
Copy link

medihack commented Jan 2, 2015

Within the normal publish method there is an easy way to cancel the publish and return nothing (just use this.ready(); return;. With publishComposite this doesn't work. I get the following exception then: Exception from sub 2BgTTyL3mgoTmRtbL TypeError: Cannot read property 'children' of undefined.

How could I just cancel the publish (and publish nothing), for example when some provided parameter is invalid?

@medihack
Copy link
Author

medihack commented Jan 2, 2015

Ok, it seems a simple return {find: function() {}} solves the problem.

@medihack medihack closed this as completed Jan 2, 2015
@fpoirier1
Copy link

Would be great something like this.cancel() though..

@reywood
Copy link
Collaborator

reywood commented Feb 17, 2015

@fpoirier1 You can simply return from a find function to accomplish that.

@fpoirier1
Copy link

Yes, this is what I am doing right now :

var cancel = function(){
  return {find: function() {}}
}

Meteor.publishComposite('projects', function(){
  // Return nothing if user is not loggedIn
  if(!this.userId)
    return cancel();

    ...

I just tought it would have been cleaner that's all.

@reywood
Copy link
Collaborator

reywood commented Feb 17, 2015

I discuss that scenario briefly in this blog post.

@fpoirier1
Copy link

I get your point. Awesome work by the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants