mardi 30 mars 2021

Ember defineProperty not reflecting on template until notifyProperty change is called?

I basically have a feature flag which gets added into a list on user saving a configuration. On save I create a computed property on a service object as showing below.

  defineFeature(feature) {
    defineProperty(this, `is${classify(feature)}`, computed('session.account.features.[]', 
     function() {
      return this.hasFeature(feature);
    }));
  },

Now this sets the property on the service object and I consume it in my .hbs file. However it does not reflect unless I trigger <serviceObj>.notifyPropertyChange('is<FlagName');

I am confused why Ember doesn't update by itself or am I doing something wrong?

Ember: v3.4




Aucun commentaire:

Enregistrer un commentaire