Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
Last active April 8, 2017 21:25
Show Gist options
  • Save nathanhammond/9dcfdde1881458b60444d85e59d8c9d6 to your computer and use it in GitHub Desktop.
Save nathanhammond/9dcfdde1881458b60444d85e59d8c9d6 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.route('standalone');
this.route('parent', { path: '/' }, function() {
this.route('child', { path: '/'});
});
});
export default Router;
import Ember from 'ember';
import somethingAsync from '../../utils/something-async';
export default Ember.Route.extend({
model() {
// WORKS: Only transition error:
// return Ember.RSVP.Promise.reject();
// DOESN'T WORK 2.0+: Throws additional error.
// Works in 1.13.
// Appears to have autorun in scope, is the default error handler.
return somethingAsync('child', 'reject');
}
});
import Ember from 'ember';
import somethingAsync from '../utils/something-async';
export default Ember.Route.extend({
model() {
return somethingAsync('parent', 'resolve');
}
});
import Ember from 'ember';
import somethingAsync from '../utils/something-async';
export default Ember.Route.extend({
model() {
// DOESN'T WORK: Same story as parent.child.
return somethingAsync('standalone', 'reject');
}
});
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "canary",
"ember-template-compiler": "canary"
}
}
import Ember from 'ember';
export default function somethingAsync(label, resolution) {
return new Ember.RSVP.Promise(function(resolve, reject) {
console.log(label, 'invoked');
setTimeout(() => {
console.log(label, resolution);
if (resolution === 'resolve') { resolve('success'); }
if (resolution === 'reject') { reject('error'); }
}, 2000);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment