mardi 4 octobre 2016

Observing ember store from component

Warning contains legacy code

I have a component that receives a model containing the majority of the data that belongs to it. However, the component has a component within it that is using global settings from the store to display data.

A user request has been made so that if changes are made to the model then it also updates the global settings store, which then updates the internal component.

I have updated ember so that it updates the store, but how can I put an observer on the store for the internal component?

I have tried the following for the internal component, but it never makes it to the observer function:

export default Ember.Component.extend({
  store: Ember.inject.service(),
  globals: Ember.computed('store', function() {
    return this.get('store').peekRecord('globals', 0);
  }),
  globalObserver: Ember.observer('globals', function() {
    console.log("Hello World");
  }
});

Is there any way to do this?




Aucun commentaire:

Enregistrer un commentaire