Skip to content

Instantly share code, notes, and snippets.

@oriSomething
Last active May 12, 2016 10:08
Show Gist options
  • Save oriSomething/5cca518556a4c4a97e957dc3bde50053 to your computer and use it in GitHub Desktop.
Save oriSomething/5cca518556a4c4a97e957dc3bde50053 to your computer and use it in GitHub Desktop.
volatile test
import Ember from 'ember';
var volatileValue = 0;
export default Ember.Controller.extend({
init() {
this._super(...arguments);
Ember.run.later(this, function interval() {
this.incrementProperty("timer");
console.log(this.get("value"));
Ember.run.later(this, interval, 1000);
}, 1000);
},
timer: 0,
dep: Ember.computed("value", function() {
var value = this.get("value");
return "dep::" + value;
}),
value: Ember.computed(function() {
return volatileValue++;
}).volatile()
});
<h1>volatile test</h1>
<br>
timer - {{timer}}
<br>
dep on volatile - {{dep}}
<ul>
<li>volatile - {{value}}</li>
<li>volatile - {{value}}</li>
</ul>
<br>
{
"version": "0.8.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": "2.5.1",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment