1

I need to add spinning loader to component. My component observing global object global.loading. I'm setting global.loading to true in beforeModel hook in my route.

The problem that there is some sort of race-condition: UI thread gets blocked by the model before loading spinner appears.

Is there any way i can delay model from beforeModel?

Or i need to come up with different strategy?

rinchik
  • 2,642
  • 8
  • 29
  • 46
  • I'm not very familiar with Ember loading states as I haven't made use of them yet but it is covered fairly well in the guide. Have you seen this info? If you have and it's not useful I apologize: (http://emberjs.com/guides/routing/loading-and-error-substates/) (http://emberjs.com/guides/routing/asynchronous-routing/) – Sarus Mar 29 '14 at 09:51

1 Answers1

2

If you return a promise from beforeModel, the transition will pause until the promise fulfills.

I can't speak to whether that will solve your specific problem, but that's how beforeModel works.

Luke Melia
  • 8,389
  • 33
  • 41
  • Excellent! If i return promise and resolve it with Ember.run.later it does the trick! Thanks a lot! – rinchik Mar 31 '14 at 13:11