Skip to content
nexisv1.3.3Build with Nexis
← All documentation

Build · guide 07

State and reactivity

Signals, computed values, resources, batching, Stores, lifecycle ownership, and direct DOM bindings.

HTML-first routestatic reference pagev1.3.3 checked

01

Signal ownership matters

Signals are callable values with .set and .setValue. Keep request-specific state in a request or render owner; do not expose private data through mutable module singletons.

02

Derived data stays derived

Use computed for pure derivations, resource for async load state, and batch for one logical group of updates. Effects are for side effects and need cleanup ownership.

03

Bind a scalar target

Direct Signal reads can lower to text bindings. Use explicit bindText$, bindValue$, bindChecked$, bindDisabled$, bindHidden$, bindClass$, bindStyle$, bindHref$, bindSrc$, or bindAriaLabel$ when intent needs to be unambiguous.

ExampleTypeScript
const count = state(0)
const increment = () => count.set((current) => current + 1)

<button onClick$={increment}>
  <output bindText$={count}>{count()}</output>
</button>

PRACTICAL LABS

Run this capability.

Each example states the observable output, the boundary that remains your responsibility, and the check that proves the result.

01

Bind a scalar target

TSX
import { state } from '@mohammedaydan/core'

const busy = state(false)

<button bindDisabled$={busy}>Save</button>
OUTPUT
Only the button disabled property changes when the Signal changes.
BOUNDARY
State in browser assets is public; never capture credentials or request-private values.
PROVE IT
Inspect data-nx-bind and confirm the component does not rerender.

02

Scope shared values explicitly

TypeScript
import { createContextScope, createContext, provideContext } from '@mohammedaydan/core'

const Locale = createContext('en')
const root = createContextScope()
const french = provideContext(root, Locale, 'fr')
Locale.use(french) // fr
OUTPUT
A child scope reads its own value without mutating the parent scope.
BOUNDARY
For async work pass an explicit ContextScope; Provider children are synchronous.
PROVE IT
Render two scopes with different values and assert isolation.

VERIFICATION

Prove the contract.

Inspect the output for binding markers, then change a Signal and confirm only the intended text or property changes.