Documentation
¶
Overview ¶
Package reactive builds a compile-time signal dependency graph from emitted component signatures. It is used to validate hydration code before it ships: dead signals, write-only effects, effects with no reads, and circular signal/effect dependencies are all detectable without executing anything.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diagnostic ¶
Diagnostic is a single validation finding.
type EffectNode ¶
type EffectNode struct {
Name string
Kind string // "effect" or "memo"
Reads map[string]bool // signal reads anywhere in the body (sync + deferred callbacks)
Writes map[string]bool // signal writes anywhere in the body (sync + deferred callbacks)
// SyncReads / SyncWrites are reads/writes at the effect's top-level scope
// (excluding nested function/arrow bodies). Only synchronous edges can
// produce a feedback loop, and only synchronous writes make an effect
// "write-only".
SyncReads map[string]bool
SyncWrites map[string]bool
// HasNested is true when the body contains nested function/arrow bodies
// (deferred callbacks like event handlers, intervals, promise chains).
HasNested bool
// HasOtherRefs is true when the synchronous body references anything other
// than setter calls (props, local variables, conditionals, etc.). Such an
// effect is doing more than a bare `setX(...)` and isn't a write-only bug.
HasOtherRefs bool
}
EffectNode is a single createEffect (or createMemo) call site.
type Graph ¶
type Graph struct {
Signals map[string]*SignalNode
Effects []*EffectNode
// contains filtered or unexported fields
}
Graph is the whole-page dependency graph.
func Build ¶
func Build(sigs []irtree.ComponentSignature) *Graph
Build assembles a Graph from the per-component signatures the emitter produces for a page.
func (*Graph) Validate ¶
func (g *Graph) Validate() []Diagnostic
Validate runs all compile-time checks and returns findings.
type SignalNode ¶
type SignalNode struct {
Name string
Setter string
// Reads / Writes key by effect name.
Reads map[string]bool
Writes map[string]bool
// Used is true if the signal is read or written by an effect, handler,
// slot binding, attribute binding, or extra variable.
Used bool
}
SignalNode tracks where a signal is read from and written to.