Computed properties in 0.8.1

27 views
Skip to first unread message

Jedidiah

unread,
Oct 26, 2016, 6:48:24 AM10/26/16
to Ractive.js
Is there a known issue with computed properties in 0.8?
I don't think I'm doing anything crazy (though it's always a possibility!).

I have two computed properties getting passed into a component, but when I update hiddenIndexes only one of the two properties will get updated.

Is there a problem with having two computed properties both observing the same path (this.get('hiddenIndexes'))? 


computed: {

  dataForVisibleKeys() {

    const hiddenIndexes = this.get('hiddenIndexes');

    const chartData = this.get('chartData');

    return stripByHiddenKeys(chartData, hiddenIndexes);

  },

  coloursForVisibleKeys() {

    const hiddenIndexes = this.get('hiddenIndexes');

    const colourPalette = this.get('colourPalette');

    return stripByHiddenKeys(colourPalette, hiddenIndexes);

  },

},




Jedidiah

unread,
Oct 26, 2016, 6:55:12 AM10/26/16
to Ractive.js
Should say it was working as expected in 0.7.3

Jedidiah

unread,
Oct 26, 2016, 10:06:42 AM10/26/16
to Ractive.js
Some more details:

View of parent component where the computed properties are set.

<chart chartData={{dataForVisibleKeys}} colours={{coloursForVisibleKeys}} />
<div>
  {{coloursForVisibleKeys}}<br>
  {{dataForVisibleKeys.length}} items
</div>


Child component where the computed properties are being passed to.
<div>
  {{.colors}}<br>
  {{.chartData.length}} items
</div>



Result:


You can see the values correctly being updated outside the component and not changing inside.

Chris Reeves

unread,
Oct 26, 2016, 12:02:58 PM10/26/16
to Jedidiah, Ractive.js
That was not a known issue. I have at least part of it resolved, with the fix available in 0.8.2. If it's not completely fixed, please open an issue on github.

Thanks for the report!


Thanks, Chris

--
You received this message because you are subscribed to the Google Groups "Ractive.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ractive-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jedidiah

unread,
Oct 26, 2016, 12:38:43 PM10/26/16
to Ractive.js, jedi...@nomnom.it
That's brilliant, thank you Chris.

Just updated to 0.8.2 and it's working perfectly again.
⚡Speedy!

Thanks,

Jedidiah.


Thanks, Chris

To unsubscribe from this group and stop receiving emails from it, send an email to ractive-js+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages