vendredi 7 août 2015

Ember: How to cleanly replace model data and have progress indicators

I have a certain route that shows a list of projects, and it gets initial data from my RESTAdapter based on who the user is.

I am now implementing a search function that will issue a new API call so the user can get records besides the default ones for them, and the response should replace the model for that route. I have all that working, but I'm not sure how to do a loading or progress indicator (as the response from the database could potentially take 5-10 seconds depending on the amount of data). I know about loading substates, but in this case I'm not transitioning between routes. I just want to have at minimum a spinner so the user knows that it's working on something.

Would anyone that's done this before be willing to share how they handled a)replacing the model with new data, and b)keeping the user informed with a spinner or something?

Form action called when user clicks the Search button

searchProjects: function() {
  var query = this.get('queryString');
  if (query) {
    var _this = this;
    var projects = this.store.find('project', {q: query});
    projects.then(function(){
      _this.set('model', projects);
    });
  }
}




Aucun commentaire:

Enregistrer un commentaire