Hi,
I would like to know how can I fire loading state while saving with RESTAdapter,
In my use case, I’m saving a record to the server with record.save()
I would like to fire loading
event where my PACE is hooked to.
To hook the PACE I follow this guide here in the forum.
My code:
// zones/new controller
export default Ember.ObjectController.extend({
actions: {
createNew: function() {
this.set('isSyncing', true);
var newZone = this.store.createRecord('zone', {
name: this.get('name'),
description: this.get('description'),
icon: this.get('icon')
});
var self = this;
// When I save the zone, if my server take for example 3s to respond, I would like to show the user that something is happen with PACE
newZone.save().then(
function(zone) {
self.setProperties({
name: null,
description: null,
icon: null,
isSyncing: false
});
self.transitionToRoute('zone', zone);
},
function() {
newZone.rollback();
self.set('isSyncing', false);
}
);
}
}
});
// loading route
export default Ember.Route.extend({
activate: function() {
this._super();
window.setTimeout(function() {
Pace.stop();
}, 10000);
Pace.restart();
return true;
},
deactivate: function() {
this._super();
Pace.stop();
return true;
}
});
Thanks!