jeudi 25 mai 2017

Ember component computed function does not rerun when data changes

I have stored a string value within a computed property like so:

clientId: Ember.computed.oneWay("_clientId")

where _clientId is defined as a property on the object like so:

export default Ember.service.extend { _clientId: null, clientId: Ember.computed.oneWay("_clientId"), updateId() {this.set("_clientId", "fe48822d-bf50-44a1-9ce0-61b06504d726"); } }

I then have a component with a computed property like so:

chartData: Ember.computed("data", function () {
    const data = this.get("data");

    const clientId = this.get("session").get("clientId");
    console.log(clientId);

    if (data && data.get("left") !== undefined && data.get("right") !== undefined) {
        return data;
    }

    this.set("_chartDisplayData", null);
    return null;
})

When I called updateId, i expected the chartData function to be re-run as the value of the clientId is changed (i verified that the value gets changed for clientId). However, the chartData function never re-runs, why is this?




Aucun commentaire:

Enregistrer un commentaire