I built my first Meteor app and I like it. In addition, now that he has real production data, he is a little slow. I get messages that "nothing happens when I click this."
Is there a way to display a boot message while redrawing templates so that the user knows that something is happening?
To illustrate this, take a look at this template (not my actual code, for simplicity):
Template.all_posts.posts = function() {
return Posts.find({'category_id': Session.get('current_category')});
}
So, if you open my console and start Session.set('current_category', 1), and let them say that it takes 2 seconds to start calculating and redrawing the templates. I would like the loading indicator to be displayed there during this 2 second period.
To be clear, I already know how to display the loading indicator. In fact, I already do this on the initial page load and hide it when all my subscriptions are ready(). I just want to know where to apply the same logic (showing and hiding the boot icon) so that it runs every time the templates are redrawn. Pseudo code will work fine:
In short, when the Meteor is busy, I want to reflect this.
Any help is much appreciated!
Edit 10/09/13:
From the documents ...
These Meteor functions run your code as reactive computation:
- Patterns
- Meteor.render and Meteor.renderList
- Deps.autorun
I think that one possible solution may begin by displaying a loading indicator when any of these “calculations” are invalidated.
, Deps.autorun, onInvalidate, :
Deps.autorun(function(computation) {
computation.onInvalidate(function() {
});
});
, , Meteor, Deps.autorun.
, , rendered , () - .
- , , , ..?