Skip to content

Instantly share code, notes, and snippets.

@michalsnik
Created August 22, 2016 23:14
Show Gist options
  • Save michalsnik/883662b7dc9d86dce5f966c5360b8630 to your computer and use it in GitHub Desktop.
Save michalsnik/883662b7dc9d86dce5f966c5360b8630 to your computer and use it in GitHub Desktop.
Service computed bug
import Ember from 'ember';
const {
Component,
computed,
inject: { service },
} = Ember;
export default Component.extend({
example: service(),
init() {
//this.get('example');
this._super(...arguments);
},
testValue: computed('example.someValue', function() {
return Math.random();
}),
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
});
export default Router;
import Ember from 'ember';
const { inject: { service } } = Ember;
export default Ember.Route.extend({
example: service(),
actions: {
setRandomValue() {
this.get('example').setRandomValue();
}
},
});
import Ember from 'ember';
export default Ember.Service.extend({
someValue: null,
setRandomValue() {
this.set('someValue', Math.random());
},
});
Value (should change when service value changes): {{testValue}}
<button {{action 'setRandomValue'}}>Change service value</button>
{{example-component}}
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment