Last active
April 15, 2018 15:02
-
-
Save ofersadgat/13b0dd883d6a37b6471489f498cc44ef to your computer and use it in GitHub Desktop.
Computed Update Count
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
counter: 0, | |
callCount: 0, | |
ocallCount: 0, | |
setCounter: Ember.on('init', function(){ | |
setInterval(function(){ | |
this.set('counter', this.get('counter') + 1); | |
}.bind(this), 1000); | |
}), | |
countGreater: Ember.computed.gt('counter', 5), | |
observeCountGreater: Ember.observer('countGreater', Ember.on('init', function(){ | |
var countGreater = this.get('countGreater'); | |
var fixedCountGreater = this.get('fixedCountGreater'); | |
if (fixedCountGreater != countGreater){ | |
this.set('fixedCountGreater', countGreater); | |
} | |
})), | |
prop: Ember.computed('countGreater', function(){ | |
this.set('callCount', this.get('callCount') + 1); | |
return 'CounterGreater is ' + this.get('countGreater'); | |
}), | |
oprop: Ember.computed('fixedCountGreater', function(){ | |
this.set('ocallCount', this.get('ocallCount') + 1); | |
return 'FixedCounterGreater is ' + this.get('fixedCountGreater'); | |
}) | |
}); |
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.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.0.1", | |
"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