# Reactivity API
Ovee.js
reactivity is based on Vue 3
reactivity system. It uses two packages:
Features are filtered from these packages, but if you ever feel like something is missing, just create a new issue! 👉 Ovee.js
Most of this documentation links to external Vue 3
docs, as they did a great job documenting all of it's features and functionalities! So for explicit explenation of every feature (except ReactiveProxy
and makeComponentReactive
), we recommend going straight there:
# ReactiveProxy
Utility class, that creates Vue 3
reactive
instance and allows you for a selective field reactivity. You can find it in Components
, that uses any decorator which requires from a component to be reactive. It's applied through helper makeComponentReactive
and you probably don't need to use it at all.
# makeComponentReactive
Applies ReactiveProxy
on a component and saves it's instance under protectedFields.REACTIVE_PROXY
, only if given object already doesn't have ReactiveProxy
applied. It's useful if you make a custom decorator which functionality is based on reactivity of a component. In any other case, you don't really need it.
# Reactive objects API
makeReactive
- Used to create reactive objects. Alias for Vue 3: reactivemakeComputed
- Used to create computed function with lazy evaluation, that reevaluates only when reactive dependencies change. Alias for Vue 3: computedreadonly
- Create readonly proxy object. Vue 3 docs: readonlyisProxy
- Check if object is Proxy created bymakeReactive
orreadonly
. Vue 3 docs: isProxyisReactive
- Check if object was created bymakeReactive
. Vue 3 docs: isReactiveisReadonly
- Check if object was ceated byreadonly
. Vue 3 docs: isReadonlytoRaw
- Returns target object ofmakeReactive
proxy. Vue 3 docs: toRawmarkRaw
- Prevent object from converting to reactive one. Vue 3 docs: markRawshallowReactive
- Creates a reactive proxy that tracks reactivity of its own properties but does not perform deep reactive conversion of nested objects (exposes raw values). Vue 3 docs: shallowReactiveshallowReadonly
- Creates a proxy that makes its own properties readonly, but does not perform deep readonly conversion of nested objects (exposes raw values). Vue 3 docs: shallowReactive
# Ref API
ref
- Creates reactive mutable object with field.value
for single value. Vue 3 docs: refunref
- Return inner value if argument isref
, else return argument untouched. Vue 3 docs: unreftoRef
- Createref
from areactive
objects single property, retaining it's reactivity. Vue 3 docs: toReftoRefs
- Same astoRef
, but for a whole object, where each field is aref
. Vue 3 docs: toRefsisRef
- Check if value isref
object. Vue 3 docs: isRefcustomRef
- Creates a customized ref with explicit control over its dependency tracking and updates triggering. Vue 3 docs: customRefshallowRef
- Creates aref
that tracks its own.value
mutation but doesn't make its value reactive. Vue 3 docs: shallowReftriggerRef
- Execute any effects tied to ashallowRef
manually. Vue 3 docs: triggerRef
# Watch API
doWatch
- Watch for changes in specified source. Alias for Vue 3: watchdoWatchEffect
- Immediate watch, that can automatically detect all reactive sources used inside. Alias for Vue 3: watchEffectmakeComputed
- Creates a cachable function that recalculates its value whenever reactive values change inside. Alias for Vue 3: computed