Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 168 forks source link

Make null publication more performant #103

Closed dalgard closed 9 years ago

dalgard commented 9 years ago

With the FastRender package, all null publications are processed on every single request, including simple resource requests. This means that the publish function will be called many times before this.userId becomes available, so its performance can be improved a lot:

// roles_server.js
Meteor.publish(null, function () {
  if (this.userId) {
    return Meteor.users.find(this.userId, {
        fields: { roles: 1 }
      });
  }

  this.ready();
});
alanning commented 9 years ago

Just released v1.2.14, which changes the null pub to a named pub.