explaingit

webreflection/signals

29Python
This is a quick first-pass explanation. The richer sections — use-cases, tech stack, setup, prompts — are still being generated.

TLDR

@webreflection/signals is a small JavaScript library that brings Preact-style reactive signals to any JavaScript environment.

Mindmap

A visual breakdown will appear here once this repo is fully enriched.

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

In plain English

@webreflection/signals is a small JavaScript library that brings Preact-style reactive signals to any JavaScript environment. After minification and compression the entire module weighs about 0.5KB. Signals in this library work the same way they do in Preact: a signal holds a value, and any computed value or effect that reads it during execution automatically subscribes to future changes. When a signal's value is updated, subscribed effects re-run and subscribed computed values are marked stale and recalculated on their next read. The library provides the core set of primitives: signal, computed, effect, batch, and untracked. A notable design decision is that effects do not track what they subscribed to. Instead, each signal or computed stores references to its subscribers. When an outer effect is running and an inner effect is encountered, the inner effect is disposed so the outer one takes sole responsibility. This prevents nested effects from creating duplicate subscriptions and ensures effects always run top-down in the correct order. The same stale guard used by computed values applies to effects: when multiple signals ask the same effect to re-run, only the first invalidation matters until that effect has actually executed again. The batch function defers subscriber notifications until the batch is complete, then filters out any subscribers invalidated before they ran. The untracked function temporarily disables subscription tracking, useful when you want to read a signal's current value without creating a dependency on future changes. The computed type adds read-only semantics: its value refreshes only when a dependency changes and the value is accessed, not eagerly. A disposable export provides a lifecycle-aware variant of effect, equivalent to Preact's createModel utility, that cleans itself up automatically when it is no longer needed. The README includes detailed in-depth explanations of each primitive through expandable sections.

Open on GitHub → Explain another repo

← webreflection on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.