Template.calendarMobile.onCreated(function () {
var instance = this;
instance.autorun(function () {
var calendarId = FlowRouter.getParam('calendarId');
instance.subscribe("events", calendarId);
});
});
Please note : instance.subscribe is being used instead of Meteor.subscribe
Why therefore when am calling Events.find().fetch() within the onRendered definition, is the generated array empty ?! Only sometime later, does it actually get populated.
I was under the impression, that {{#if Template.subscriptionsReady}} would prevent the DOM creation of the template innards until the Template’s own subscriptions & thus data, have actually been populated; and this would in turn call the onRendered function of the Template.
Are the two (cursor vs data) mutually exclusive from a readiness point of view ?
Or is there something else that I am simply not understanding ?
When you get a minute; can you share why that is necessary; namely why do we have to be so granular, almost to the control / component for the template rendering and subscription management to work in concert?
Again, thank you; just want to understand the cause now.
That’s because our data is traveling down a socket. And our code is running whenever the hell it wants.
When subscribe there is some
Latency until we get all our data, so it’s best not to make assumptions about what your UI can do before you get ready. I’ve been bitten in the past by making assumptions about subscription state only to have my data be undefined then a value later. Be granular. It’ll save you from killing someone