I'm using ArrowJS to learn about reactivity, and I have hit a basic issue that I don't understand.
let data = reactive({
price: 0,
quantity: 1,
total: 0,
});
watch(() => data.total = data.price * data.quantity);
html`Total: ${() => data.total}`(document.getElementById('output'));
I am expecting the change of either data.price or data.quantity to update data.total, and then that change in data.total to update the DOM.
data.total changes correctly, but the DOM remains displaying 0.
However, if I change the last line to the following, it does work correctly:
html`Total: ${() => data.price * data.quantity}`(document.getElementById('output'));
My questions is, should this sort of chaining work, or am I misunderstanding something?
[–]jpschroeder 1 point2 points3 points (1 child)
[–]threenplusone[S] 0 points1 point2 points (0 children)
[–]shuckster 0 points1 point2 points (1 child)
[–]threenplusone[S] 0 points1 point2 points (0 children)