Skip to content

Instantly share code, notes, and snippets.

@les2
Last active February 28, 2017 00:17
Show Gist options
  • Save les2/6b90431bf28b9f0e478cf83b53f8dd0f to your computer and use it in GitHub Desktop.
Save les2/6b90431bf28b9f0e478cf83b53f8dd0f to your computer and use it in GitHub Desktop.
select is not broken, or is it?
import Ember from 'ember';
export default Ember.Component.extend({
targetAction: 'mostAwesomeAction',
doSomething() {
this.sendAction('targetAction', 'this value is the greatest value');
}
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
myService: Ember.inject.service(),
});
import Ember from 'ember';
export default Ember.Mixin.create({
myService: Ember.inject.service(),
count: 0,
actions: {
mostAwesomeAction(value) {
this.incrementProperty('count');
this.get('myService').set('awesomeValue', value + this.get('count'));
}
}
})
import Ember from 'ember';
import MyMixin from '../mixins/my-mixin';
const DummyMixin = Ember.Mixin.create({});
export default Ember.Route.extend(DummyMixin, MyMixin, {
actions: {
}
});
import Ember from 'ember';
export default Ember.Service.extend({
awesomeValue: 'nothing yet',
});
<p>This value should be updated by action defined in mixins/my-mixin when you click on the button:</p>
<p>Value from service: {{myService.awesomeValue}}</p>
<h2>No Nesting</h2>
<p>This component is not nested in another component and therefore propagates action up:
{{my-component text='this button should update value'}}</p>
<h2>Nesting</h2>
<p>This button is wrapped in an extra component so it does <strong><em>NOT</em></strong> bubble the route action: {{outer-component text='this button should NOT work'}}</p>
<button {{action (action doSomething)}}>Click on Me: {{text}}</button>
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "release",
"ember-data": "2.11.0",
"ember-template-compiler": "release",
"ember-testing": "release"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment