useCondition
Stable · since 0.1.0
Registers a pull-only condition getter on a trigger. The runtime calls getter() only at fire time — there is no subscription, and the component does not re-render when the trigger fires.
deps works like useMemo: when any element changes, the runtime sees the updated closure.
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
trigger | Trigger<S> | The trigger returned by createTrigger. |
name | K extends ConditionKey<S> | A condition declared in the trigger’s schema. |
getter | () => ConditionMap<S>[K] | A synchronous function returning the current value. |
deps | readonly unknown[] (default []) | Same semantics as useMemo — when any element changes, the captured closure is refreshed. |
Returns
Section titled “Returns”void. Registration is performed in useEffect and cleaned up on unmount.
Examples
Section titled “Examples”Basic provider
Section titled “Basic provider”Without deps (a stable getter)
Section titled “Without deps (a stable getter)”If your getter reads from a ref or a module-level value, deps is unnecessary:
From an external store (Zustand example)
Section titled “From an external store (Zustand example)”For a zero-rerender adapter that bypasses the React state path, use @triggery/zustand.
Related
Section titled “Related” useEvent Fire events from producers.
useAction Register an action handler.
Conditions guide The full narrative on pull-only, snapshots and ownership.
@triggery/zustand Use a Zustand store as a condition without re-rendering.