How do you suppress the initial load when observing changes on a collection with observeChanges
.
I’ve seen this post on stackoverflow but the solution is not working for me. I suspect it’s because I’m running it on the client-side.
Here is my code:
var posts = null;
var init = true;
Template.mainChat.helpers({
posts: function() {
posts = Posts.find();
return posts;
}
});
Template.mainChat.onRendered(function() {
posts.observe({
added: function() {
if (!init)
console.log('foo');
}
});
init = false;
});
I’ve also tried placing init = false
after posts = Posts.find()
but that didn’t work either. console.log('foo')
is still executing for every document found and not only on new additions to the collection.
Thanks