Skip to content

Instantly share code, notes, and snippets.

@dr-dimitru
Created March 9, 2021 11:50

Revisions

  1. dr-dimitru created this gist Mar 9, 2021.
    14 changes: 14 additions & 0 deletions accounts_client.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // !!! THIS IS META CODE, NOT A REAL SUGGESTION TO A CODEBASE
    // JUST VERY SIMPLIFIED FORM OF PROPOSAL

    Meteor._user = new ReactiveVar(null);
    Meteor._userId = new ReactiveVar(null);
    Tracker.autorun(() => {
    Meteor._user.set(Meteor.user() || null);
    });
    Tracker.autorun(() => {
    Meteor._userId.set(Meteor.userId() || null);
    });
    Template.registerHelper('currentUser', () => Meteor._user.get());
    Meteor.user = Meteor._user.get.bind(Meteor._user);
    Meteor.userId = Meteor._userId.get.bind(Meteor._userId);