Last active
July 29, 2016 18:36
-
-
Save kumkanillam/776ffb2be7e129655ef62e59b2dc8697 to your computer and use it in GitHub Desktop.
Service - Array observer sample
This file contains hidden or 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({ | |
cart:Ember.inject.service(), | |
actions:{ | |
addEntry(){ | |
this.get('cart').addEntry(); | |
} | |
} | |
}); |
This file contains hidden or 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.Service.extend({ | |
bucket:['initial'], | |
addEntry(){ | |
console.log('entry added'); | |
this.get('bucket').pushObject('added'); | |
}, | |
bucketListener: Ember.observer('bucket.@each',function(){ | |
Ember.run.once(this,'bucketChange'); | |
}), | |
bucketChange(){ | |
console.log('bucketChange'); | |
} | |
}); |
This file contains hidden or 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.3", | |
"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