Skip to content

Instantly share code, notes, and snippets.

@brendan-rius
Last active February 1, 2016 22:08
Show Gist options
  • Save brendan-rius/67430930263c65915d02 to your computer and use it in GitHub Desktop.
Save brendan-rius/67430930263c65915d02 to your computer and use it in GitHub Desktop.
intermediateTransitionTo()
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
// We simulate a model that would take 5 seconds to be loaded
return new Promise((resolve, reject) => {
Ember.run.later(() => {resolve();}, 5000);
});
},
actions: {
loading(transition, originRoute) {
// Called while the model loads, but throws an exception
this.intermediateTransitionTo('loading', {});
// This would not throw an exception: this.intermediateTransitionTo('loading');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment