I have an application that loads 50 chapters at once. While the chapters are being viewed, I want the application to play a sound when a new chapter’s been loaded. This is how I think it’s supposed to be done
Chapters.find().observe({
added: function (user) {
playSound()
}
});
However this spams the sound on initial load, not just subsequent new chapters. How do I get it to only sound off on new chapters?
Edit: Looking for a Meteor answer, rather than, setTimeout or something. Though I’ll do that if I have to.
You could wait for the first complete load of chapters before adding the
observecallbacks.Of course you should add the observer only once, not every time the subscribe-callback fires.