Last active
April 8, 2017 21:25
-
-
Save nathanhammond/9dcfdde1881458b60444d85e59d8c9d6 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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
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; |
This file contains hidden or 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
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'); | |
} | |
}); |
This file contains hidden or 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
import Ember from 'ember'; | |
import somethingAsync from '../utils/something-async'; | |
export default Ember.Route.extend({ | |
model() { | |
return somethingAsync('parent', 'resolve'); | |
} | |
}); |
This file contains hidden or 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
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'); | |
} | |
}); |
This file contains hidden or 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
{ | |
"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" | |
} | |
} |
This file contains hidden or 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
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