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
Post a Comment