Documentation
¶
Overview ¶
Package reactive implements an owner-scoped, synchronous signal graph. A graph belongs to one goroutine. Components build once; computations track only the signals/memos read during their current evaluation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrDisposed = errors.New("reactive: graph or owner is disposed") ErrCycle = errors.New("reactive: cyclic computation") ErrRunaway = errors.New("reactive: effect exceeded 1000 executions in one flush") ErrMemoWrite = errors.New("reactive: memo calculations cannot write signals") ErrFlushWrite = errors.New("reactive: settled callbacks cannot write reactive state") )
Functions ¶
Types ¶
type Effect ¶
type Effect struct {
// contains filtered or unexported fields
}
Effect reruns after dependencies change. Each evaluation gets a fresh child scope whose cleanup runs before reevaluation. The initial run is synchronous unless created inside a batch or another running computation.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
func (*Graph) Batch ¶
Batch groups writes. Values change immediately; effects and settled callbacks run after the outer batch. Reads of stale memos update them on demand. Errors do not roll back writes which have already happened.
type Memo ¶
type Memo[T any] struct { // contains filtered or unexported fields }
Memo caches a pure derived value. Downstream computations observe its value version, so equal results suppress effects even when source signals changed.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope owns computations, nested scopes and cleanup callbacks. Disposing an owner unsubscribes effects and releases children in reverse creation order.
type Signal ¶
type Signal[T any] struct { // contains filtered or unexported fields }
Signal is an immutable-by-convention value cell. The default equality uses reflect.DeepEqual; pass an equality function, or nil to always notify. Existing signal values can outlive an owner; disposed computations no longer observe it.