Permalink
Browse files

More correct pattern for publishing user.

Long, but probably better to show the pedantically correct thing so users don't
get hurt if they copy, paste and modify.

Fixes #1885
  • Loading branch information...
1 parent f9c947a commit 8924417e23efb986984c5b77f5e1b6b8ea706591 @n1mmy n1mmy committed Mar 4, 2014
Showing with 11 additions and 3 deletions.
  1. +11 −3 docs/client/api.html
View
@@ -1585,11 +1585,19 @@ <h2 id="accounts_api"><span>Accounts</span></h2>
published to the client. You can publish additional fields for the
current user with:
- Meteor.publish(null, function () {
- return Meteor.users.find({_id: this.userId},
- {fields: {'other': 1, 'things': 1}});
+ // server
+ Meteor.publish("userData", function () {
+ if (this.userId) {
+ return Meteor.users.find({_id: this.userId},
+ {fields: {'other': 1, 'things': 1}});
+ } else {
+ this.ready();
+ }
});
+ // client
+ Meteor.subscribe("userData");
+
If the autopublish package is installed, information about all users
on the system is published to all clients. This includes `username`,
`profile`, and any fields in `services` that are meant to be public

0 comments on commit 8924417

Please sign in to comment.