index.observe
observe<T>(target, hooks): () => void
Attaches scoped reactivity lifecycle hooks to a specific reactive target object, domain model, or store.
| Name | Type | Description |
|---|---|---|
T |
extends object |
The type of target object or store. |
| Name | Type | Description |
|---|---|---|
target |
T |
The reactive object or store to observe. |
hooks |
ReactivityHooks |
Reactivity lifecycle hooks to attach. |
fn
An unsubscribe function to detach the hooks from the target.
(): void
void
Remarks
Unlike global hooks, scoped hooks only receive notifications when the specified target object or its nested reactive properties are tracked or mutated.
Example