Skip to content

Instantly share code, notes, and snippets.

@djfrsn
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save djfrsn/ae193359c4ce9a2bde54 to your computer and use it in GitHub Desktop.

Select an option

Save djfrsn/ae193359c4ce9a2bde54 to your computer and use it in GitHub Desktop.
Meteor Template Level Subscriptions
<template name="dashboardSlideOut">
{{> accountsBreadcrumb}}
{{#if Template.subscriptionsReady}}
<ul class="collection">
{{#each libSections}}
<li class="collection-item">{{ libSection }}
<i class="material-icons">heart</i>
</li>
{{/each}}
</ul>
{{else}}
<div class="loading">
{{#if slow}}
<div class="progress">
<div class="indeterminate"></div>
</div>
{{/if}}
</div>
{{/if}}
</template>
// Template.dashboardSlideOut.events = {
// "click .link": buttonCollapse = function ( e, t ) {
// }
// };
Template.dashboardSlideOut.onCreated(function() {
var instance = this;
instance.slow = new ReactiveVar(false);
// Subscription
instance.subscribe('lib');
// Cursor
instance.LibSections = function() {
return LibSections.find({});
}
});
Template.dashboardSlideOut.onRendered(function() {
});
// Template.dashboardSlideOut.onDestroyed(function() {
// });
Template.dashboardSlideOut.helpers({
libSections: function() {
return Template.instance().LibSections();
},
slow: function() {
var instance = Template.instance();
slow = instance.slow.get();
Meteor.setTimeout(function() {
instance.slow.set(true);
}, 200);
console.log("slow", slow);
return slow;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment