meteor-roles icon indicating copy to clipboard operation
meteor-roles copied to clipboard

Make auto-subscriptions wait until there is a logged in user

Open jankapunkt opened this issue 4 years ago • 3 comments

This kind of a question / feature request.

Currently the package's client code automatically subscribes to the roles and immediately causes data being loaded.

I would like to defer this step until my users are actually logged in reducing the initial data load when starting the app. I know this is just a tiny performance improvement but many of these small things add up in the end.

Proposed solution:

Tracker.autorun(function () {
  if (!Meteor.userId()) return
  Roles.subscription = Meteor.subscribe('_roles')
})

I assume, that the information about user roles on the client makes no sense until there is not a logged in user (correct me if there is a usecase, that contradicts this assumption). Therefore this should not have any negative impact on current setups.

I could provide a PR for this

jankapunkt avatar Jan 13 '21 10:01 jankapunkt

I'd say this is a good candidate for the next major version 😎 #295

SimonSimCity avatar Jan 13 '21 23:01 SimonSimCity