Since the meteorite does not provide you with a handle to the current subscription, there is no obvious way to wait for data. Here are a few options:
use guard
A typical way to solve this problem is to add guards to your code. In your template (s) that are experiencing this problem, you can write something like:
var user = Meteor.user(); var lastMsgRead = user && user.profile && user.profile.lastMsgRead;
If you find that you write a lot of this code, you can include it in a general function:
var extractProfileValue = function(key) { var user = Meteor.user(); return user && user.profile && user.profile[key]; };
And use it as follows:
var lastMsgRead = extractProfileValue('lastMsgRead');
show spinner
You can check the user profile in the template itself:
<template name='myTemplate'> {{#unless currentUser.profile}} // show spinner or loading template here {{else}} // rest of template here {{/unles}} </template>
If you need this experience on all of your pages, you can add it to your layout template.
backup publisher
WARNING: I have not tried this
One way to get a custom subscription descriptor is to simply add the redundant publisher and subscribe to it:
Meteor.publish('myProfile', function() { return Meteor.users.find(this.userId, {fields: {profile: 1}}); });
Then in your router:
waitOn: function () { return Meteor.subscribe('myProfile'); }
source share