Last active
January 2, 2016 02:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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