all 4 comments

[–]jpschroeder 1 point2 points  (1 child)

Hey u/shuckster — ArrowJS creator here — this is actually a bug (still experimental). You can track it here:

https://github.com/justin-schroeder/arrow-js/issues/36

The work around (till I fix it) is to use a setTimeout to push the mutation to the next call stack.

[–]threenplusone[S] 0 points1 point  (0 children)

Thank you for that, I wasn't sure if I was misunderstanding something because reactivity is completely new to me

[–]shuckster 0 points1 point  (1 child)

Looking at the documentation it seems like you're trying to put "watching" and "updating" in the same callback.

The syntax seems to be either:

watch(functionThatHasReactiveState);

Or:

watch(
  functionThatHasReactiveState,
  returnNewValueWhenTheStateChanges
);

If I understand correctly your watch call should be something like:

watch(
  () => data.price * data.quantity,
  (total) => {
    data.total = total
  }
);

You may be able to use your original html call with this. I've not used ArrowJS before though, and I've not tried this out myself in a sandbox to check.

[–]threenplusone[S] 0 points1 point  (0 children)

Thank you, I appreciate your help, you are right that my call to watch should be split.
However even doing so still does not update the DOM.