Skip to content

1.5.0: Optimization on state derivations and side effects

Compare
Choose a tag to compare
@Tao-VanJS Tao-VanJS released this 14 Mar 16:50
· 111 commits to main since this release

1. Optimization on state derivations

Major optimization on how state derivations are being executed. For instance, with the code:

const a = van.state(3), b = van.state(5)
const s = van.derive(() => a.val + b.val)

If we have:

++a.val
++b.val

s will be derived only once.

And if we have:

++a.val
--a.val

The derivation of s will be skipped since a remains unchanged after ++a.val and --a.val.

2. rawVal property for State objects

rawVal property for State objects for getting the current value of the State object (peeking) without registering the state as a dependency of the binding function. For instance, the derived state: van.derive(() => a.rawVal + b.val) will be updated when b changes, but won't be updated when a changes.

See the release announcement: #290