Skip to content

Instantly share code, notes, and snippets.

@jasonmit
Last active January 2, 2016 02:09
Show Gist options
  • Save jasonmit/8235003 to your computer and use it in GitHub Desktop.
Save jasonmit/8235003 to your computer and use it in GitHub Desktop.
Ember: Loading Substate Entry Threshold - Prevents the loading substate from entering when not needed
var ApplicationRoute = Ember.Route.extend({
actions: {
/*
* Ensures that the loading substate is not entered until at least
* 500ms of waiting for the model to resolve
*/
loading: function() {
var scheduledIntermediate = Ember.run.later(this, function() {
this.intermediateTransitionTo('loading');
}, 500);
this.router.one('didTransition', function() {
Ember.run.cancel(scheduledIntermediate);
});
return false;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment