Skip to content

Instantly share code, notes, and snippets.

@fivetanley
Last active November 7, 2016 22:03
Show Gist options
  • Save fivetanley/1dc340a6db37c06f9cdc45aca7018211 to your computer and use it in GitHub Desktop.
Save fivetanley/1dc340a6db37c06f9cdc45aca7018211 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
Ember.Controller.reopen({
transitionToRoute(routeName, ...params) {
const anyNonPrimitives = params.find(p => typeof p === 'object' && p !== null);
console.log('params', params);
console.log('anyNonPrimitives', anyNonPrimitives);
if (anyNonPrimitives) {
throw new Error('this is the worst feature like honestly. use non-objects like strings and numbers plz');
}
return this._super(routeName, ...params);
},
});
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
doTheThing() {
this.transitionToRoute('foo', { object: 'is bad' });
}
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('foo', {path: '/foo/:id'});
});
export default Router;
<h1>Welcome to {{appName}}</h1>
<button {{action "doTheThing"}}>Do THe Thing</button>
<br>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.10.6",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment