Last active
April 28, 2019 21:51
-
-
Save ykaragol/a0039573de71b341f33d81f6d6abc47f to your computer and use it in GitHub Desktop.
service injection bug
This file contains 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 Component from '@ember/component' | |
import { inject as service } from '@ember/service' | |
import { computed } from '@ember/object' | |
import { alias } from '@ember/object/computed' | |
export default Ember.Component.extend({ | |
myService: service(), | |
init() { | |
this._super(...arguments) | |
console.log(this.myService) | |
}, | |
y: computed('myService.x', function() { | |
// if (Math.floor(Math.random()*2) > 0) { | |
// console.log(this.get('myService.x')) | |
// } | |
return Math.floor(10*Math.random()) | |
}), | |
z: alias('myService.x'), | |
t: computed('z', function() { | |
return Math.floor(10*Math.random()) | |
}) | |
}); |
This file contains 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 Component from '@ember/component' | |
import { inject as service } from '@ember/service' | |
import { computed } from '@ember/object' | |
import { alias } from '@ember/object/computed' | |
export default Component.extend({ | |
myService: service(), | |
init() { | |
this._super(...arguments) | |
// console.log(this.myService) | |
}, | |
y: computed('myService.x', function() { | |
// if (Math.floor(Math.random()*2) > 0) { | |
// console.log(this.get('myService.x')) | |
// } | |
return Math.floor(10*Math.random()) | |
}), | |
z: alias('myService.x'), | |
t: computed('z', function() { | |
return Math.floor(10*Math.random()) | |
}) | |
}); |
This file contains 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 Controller from '@ember/controller'; | |
export default Controller.extend({ | |
}); |
This file contains 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 Service from '@ember/service' | |
import { later } from '@ember/runloop' | |
export default Service.extend({ | |
init() { | |
this.set('x', 4); | |
this.next(); | |
}, | |
increment() { | |
this.incrementProperty('x'); | |
console.log(this.get('x')) | |
}, | |
next() { | |
later(this, this.timer, 3000); | |
}, | |
timer() { | |
this.increment(); | |
this.next(); | |
} | |
}); |
This file contains 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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment