Enhance value with plain and explicit reactive wrapper. Think of it as hook-style signals.
Legacy versions: v5
- Plain reactivity.
Without the implicit-cast Proxy magic like Vue Reactivity and MobX. - Single-layer shallow reactivity.
It does not convert the value withObject.defineProperty
norProxy
. Keeping everything as plain JavaScript value makes it easier to work with other libraries and easier for the JavaScript engine to optimize. - Safe and fast lazy computation.
It solves multi-level derivation issue (like in Svelte Stores) with smart lazy value evaluation. - Weak side effects.
Val
s are managed withFinalizationRegistry
andWeakRef
which means you can create and access derivedVal.value
without worrying about memory leaks. Disposers returned by subscriptions can also be easily managed with libraries like@wopjs/disposable
. - Explicit.
Reactive objects are easy to tell since their types are different from normal objects. Subscription also requires explicit dependency declaration which reduce the work of repetitive dynamic dependency collection in Proxy/Signal implementations. - Simple DX.
Designed with ergonomics in mind. No hidden rules for getting or setting values. What you see is what you get.
npm add value-enhancer