ember.js - Observe Ember Data store changes in component -


i have component creates record specific model this:

export default ember.component.extend({      store: ember.inject.service(),      addrecord(account) {       this.get('store').createrecord('update', {         authuid: account.get('authuid'),         service: account.get('platform')       });     } }); 

i have component needs observe changes done particular model (i.e. if records added or deleted), , show them in component.

export default ember.component.extend({     store: ember.inject.service(),      observestorechanges: /*what should write every time `addrecord` pushes record in store, function executed in component*/  }); 

if you're fan of observer pattern:

// store.js export default ds.store.extend(ember.evented, {     createrecord() {         const record = this._super.apply(this, arguments);         this.trigger('recordcreated', record);         return record;     } });  // component.js export default ember.component.extend({     observesstorechanges: function(record) {      }.on('store.recordcreated') }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -