samedi 30 mai 2015

Extra information in `loading` substate

I have an Ember app. In a given route, I have a handcrafted model that is not loaded immediately. Thus, I hand it over as a promise:

export default Ember.Route.extend({
  model() {
    return MyModel.create().promise();
  }
})

Don't worry too much about how MyModel works. The important bit is that it returns an RSVP promise.

As a result, Ember transitions to a loading route. There, I have a template that renders correctly showing a spinner, transitioning to the correct route once the promise is resolved.

My question is: how can I show real progress? MyModel does something relatively complex, with several steps, and I would like to show actual progress on these steps. Instead of a stateless spinner, I would like to show stateful progress. MyModel (or rather, its promises) knows about its progress, but I don't know how to communicate it down to the template.

I implemented a route and a controller for this loading state. Both load correctly, but neither seems to have access to anything that may help here. In fact, I can't see that RSVP promises even have a progress handler, like other libraries do. Am I missing something?




Aucun commentaire:

Enregistrer un commentaire