-
-
Notifications
You must be signed in to change notification settings - Fork 0
Reactivity Signals And Effects
signal(value)
computed(() => value)
watch(source, callback)
watchEffect(effect)Status: Current.
Effuse uses fine-grained reactive dependencies. Reading a signal inside a tracked computation subscribes that computation to later writes.
const count = signal(0);
count.value += 1;const total = computed(() => price.value * quantity.value);Computed values are read-only signals and update from their dependencies.
watch(
count,
(next, previous, onCleanup) => {
const request = startRequest(next);
onCleanup(() => request.abort());
},
{ immediate: true }
);watch observes one source. watchMultiple observes a typed tuple of signals or
getter functions. watchEffect discovers dependencies from the effect body.
The core package also exports reactive, readonly, shallowReadonly,
isReactive, isReadonly, toRaw, and markRaw.
Use signals for explicit scalar ownership. Use reactive objects when object shape and property-level access are the natural domain model.
Signals can be passed into JSX children. The renderer tracks and updates the dependent DOM work. The compiler package can optimize JSX/TSX transformation, but runtime reactivity does not depend on a virtual DOM.
Effects created in component script or hook contexts should be disposed with
their lifecycle. Standalone effects return handles with stop() for explicit
ownership.
- Async work is not automatically cancelled unless the API exposes or registers cleanup.
- Ordinary variable reads are not reactive.
- A computed getter should be pure; use effects for external synchronization.
- Deep watching traverses object graphs and should be used deliberately.