Show loading page when saving model data

You’d better clear the flag in a finally block, so that the spinner is turned off even when an error happens:

export default Ember.Route.extend({  
    isShowingSpinner: false,

    actions: {
        signUp(userInfo) {  
            this.user = this.store.createRecord('user', userInfo); 

            this.set('isShowingSpinner', true);

            this.user.save().finally(function() { 
              this.set('isShowingSpinner', false);
            });  
        }
    }, 
});
1 Like