mercredi 27 juillet 2016

Partially render a screen in Ember.js when some data doesn't load

I have an Ember route with a model that loads data from a few different places, using Ember.RSVP.hash. Each of these results in a call to a different API route in the backend:

export default Ember.Route.extend(AuthenticatedRouteMixin, {
    model() {
        return Ember.RSVP.hash({
            profile: this.store.queryRecord('profile', {}),
            subscriptions: this.store.findAll('subscription'),
            packages: this.store.findAll('package'),
        });
    },
});

The problem I'm having is that when any of the data calls throws an error, the entire template fails to load. What I would like to do instead is display as much data as is available even in case of an error, with the portions that couldn't be loaded displayed as an empty model of the appropriate type (with some additional error information). However, I don't seem to be able to do this. I tried adding an error handler to the route, but from the error handler there doesn't seem to be any way to continue the transition despite the error.




Aucun commentaire:

Enregistrer un commentaire