veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
202 stars 29 forks source link

endWaiting() stop spinner #14

Closed valorloff closed 7 years ago

valorloff commented 7 years ago

Hi! Unexpected problems with dynamic import: i want render spinner in layout, who is in waitOn and not loaded yet :) had to make temporary layout for spinner, but... how can I stop render of loading spinner in this hook? and why life cycle of whileWaiting does not stop?

dr-dimitru commented 7 years ago

i want render spinner in layout, who is in waitOn and not loaded yet :)

Well, spinner template is something what used many times through app, and code is small enough to put it into main bundle.

how can I stop render of loading spinner in this hook?

endWaiting is useful for many things, not only spinner. Speaking about loading spinner - if you have rendered a spinner template inside whileWaiting hook, it will be replaced in action or onNoData hook, so no need to actually sop something.

Other case for endWaiting and whileWaiting is then spinner is on the top-level DOM (for example in body template and it is always there) as overlay, where whileWaiting triggers it to show and endWaiting to hide, while templates being rendered in background

and why life cycle of whileWaiting does not stop?

What do you mean? It's triggered once in parallel with waitOn

valorloff commented 7 years ago

it has now become much clearer, thanks! I decided import needed template locally and redone wait part like this:

  whileWaiting() {
    import '/..../layout.html';
    BlazeLayout.render('mainLayout', {content:'loading'});
  },

In FR-extra are so many useful and interesting features..... Unlimited possibilities!

dr-dimitru commented 7 years ago
  whileWaiting() {
    import '/..../layout.html';
    BlazeLayout.render('mainLayout', {content:'loading'});
  },

import in this case is the same as placing it in parent scope:

import '/..../layout.html';
route({
  whileWaiting() {
    BlazeLayout.render('mainLayout', {content:'loading'});
  },
});

In FR-extra are so many useful and interesting features..... Unlimited possibilities!

I'm glad you've found it useful :)

dr-dimitru commented 7 years ago

Feel free to reopen it in case if the issue still persists on your end.

shizznet commented 7 years ago

Can you give a detailed example of using spinner in whilewaiting and endwaiting. I'm unable to get it right. It gives me the following error "No such layout" while trying to render using the following command. this.render('mainLayout', 'spinner') where mainlayout is my layout with yeild and spinner is a template with laoding html.