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
Why does Meteor.userId() throw an error when used in a publication? #2734
Comments
@rjk This has always been the case. I suspect its different because of the way reactivity works in publish functions. They're not technically reactive and will re-run regardless of whether you use |
I know, I wasn't reporting it as a bug or anything — I'm just curious if there is a good reason it is like this. Because it would be a lot easier for package developers (and less confusing for everybody) if Regarding reactivity; publish functions will not rerun indeed, but this doesn't have much to do with |
This might be awkward, but it is working as intended and we are trying to keep our GitHub issues limited to actual bugs. One way to think about it is that |
Due to the following code,
Meteor.userId()
will throw the following error when used inside a publication function:Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
Is there a good reason for breaking the consistency of this API? I understand you can use
this.userId
in your code, but in packages this is not possible. Would it be possible to store the userId for the current subscription somewhere in the core, and access that inMeteor.userId()
?The text was updated successfully, but these errors were encountered: