Meteor-Community-Packages / Meteor-Community-Packages/meteor-roles

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

Open
#331 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
913
Forks
167
PR merge metrics
No merged PRs in 30d

Description

This kind of a question / feature request.

Currently the package's [client code automatically subscribes to the roles](https://github.com/Meteor-Community-Packages/meteor-roles/blob/master/roles/client/subscriptions.js) 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:

```javascript
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading roles/client/subscriptions.js, the file linked in the issue, and compare its current automatic subscription behavior with the proposed login-gated behavior. Verify that the roles subscription is deferred until a user is logged in and that existing package checks still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authorization
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.