State management seems a bit counter intuitive at a glance.
I found this statement to be confusing; https://vanjs.org/tutorial#state-val-is-immutableWhile you can update State objects by setting the val property, you should never mutate the underlying object of val itself.
Then beneath is an example of the following;
const text = van.state("VanJS")
...
input({type: "text", value: text, oninput: e => text.val = e.target.value})
Which looks like a mutation - after reading a bit more around it is clearer that .val has a setter; but at a glance it just isn't obvious what is happening which I feel isn't intuitive.
States are mutable whose value can be get/set via the ".val" property. However, the value of the states should be (ideally) an immutable object (or primitives).
I found this statement to be confusing; https://vanjs.org/tutorial#state-val-is-immutable While you can update State objects by setting the val property, you should never mutate the underlying object of val itself.
Then beneath is an example of the following;
Which looks like a mutation - after reading a bit more around it is clearer that .val has a setter; but at a glance it just isn't obvious what is happening which I feel isn't intuitive.