mardi 27 septembre 2022

Listening to a service property change in an EmberJs Octane Component

I am wondering how on Emberjs Octane to fire a function in a component after a service property changes. Here is an example of how I did it before octane.

child-component.js before Octane

import Component from '@ember/component';
import {inject as service} from '@ember/service';
import {computed, observer} from '@ember/object';
import { isEmpty } from '@ember/utils';
import { on } from '@ember/object/evented';
export default Component.extend({

userAccount: service(),
childNavigation: service(),

whenUserChanges: on('init', observer( 'userAccount.user', 'childNavigation.{activeIgdiMeasure,currentChild}', function () {

        this.getChildItems();
    }))
})

Observers aren't recommended and @tracked isn't working on a service so I am not sure how to convert the whenUserChanges function to Octane.




Aucun commentaire:

Enregistrer un commentaire