lundi 28 mars 2016

Observing changes to an embedded record of an ember-data model

I have an Ember component that is passed a model:

export default Ember.Route.extend({
  model()  {
    return this.store.findAll('source');
  },
}

source has many nested embedded records. models/source.js is defined as:

export default Model.extend({
  displayName: attr('string'),
  azureStorageName: attr('string'),
  sourceInstances: DS.hasMany('source-instance')
});

models/source-instance.js:

export default Model.extend({
  status: attr('number'),
  creatorId: attr('number'),
  blobName: attr('string'),
  created: attr('date'),
  conversionLogs: DS.hasMany('conversion-log')
});

and so on...

My controller periodically polls the backend for source data, and I can see this reflected in Ember Observer, with the embedded documents being updated successfully. From the component, I would like to react to changes to the embedded records of the source records. I have looked at the following QAs and some others and still cannot figure out a way:

Observe Ember Data store changes in component

How to observe for changes in the Ember data store?

What is the simplest way to be able to observe changes to embedded records of an ember-data model? Note that these embedded records do not have endpoints on the backend.

I am using Ember 2.4.3.




Aucun commentaire:

Enregistrer un commentaire