ReactiveEngine class abstract
The reusable reactive-graph engine of all_observer — public and
designed for third parties to build their own reactive layers on top,
the same way all_observer's own core will (engine v2, Fase 2).
The engine owns only graph mechanics: linking, unlinking, push-phase marking (propagate) and pull-phase staleness confirmation (checkDirty). It has no policy: what "update a node" means, how effects are scheduled, and what happens when a node loses its last subscriber are all delegated to the three abstract hooks — update, notify and unwatched.
The propagation model is push-pull: a write pushes cheap flag marks
through the graph (propagate marks subscribers pending/dirty and
notify-schedules watchers), and actual recomputation is pulled lazily
— a node confirms staleness with checkDirty only when its value is
read. A derived node nobody reads never recomputes.
O motor reutilizável de grafo reativo do all_observer — público e
projetado para que terceiros construam suas próprias camadas reativas em
cima, do mesmo jeito que o próprio core do all_observer fará (motor
v2, Fase 2).
O motor possui apenas a mecânica do grafo: ligar, desligar, marcação da fase push (propagate) e confirmação de obsolescência da fase pull (checkDirty). Ele não tem política: o que significa "atualizar um nó", como effects são agendados e o que acontece quando um nó perde seu último subscriber são delegados aos três hooks abstratos — update, notify e unwatched.
O modelo de propagação é push-pull: uma escrita empurra marcações
baratas de flags pelo grafo (propagate marca subscribers como
pending/dirty e agenda watchers via notify), e a recomputação real
é puxada preguiçosamente — um nó confirma obsolescência com checkDirty
apenas quando seu valor é lido. Um nó derivado que ninguém lê nunca
recomputa.
- Implementers
Constructors
- ReactiveEngine()
-
Const constructor so concrete engines can be compile-time singletons.
Construtor const para que motores concretos possam ser singletons de
tempo de compilação.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkDirty(
ReactiveLink link, ReactiveNode sub) → bool -
Pull phase: walks
sub's dependencies starting atlinkand confirms whether anything upstream actually changed, calling update on stale mutable dependencies along the way (deepest first, iteratively). Returnstrueifsubmust recompute. This is what makespendingcheap: a maybe-stale node only does real work when someone pulls it. -
isValidLink(
ReactiveLink checkLink, ReactiveNode sub) → bool -
Whether
checkLinkis currently an edge ofsub's dependency list. Used by propagate to validate self-dependency scenarios. -
link(
ReactiveNode dep, ReactiveNode sub, int version) → void -
Records that
subdepends ondepin tracking cycleversion. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
ReactiveNode node) → void - Called during propagate for nodes flagged ReactiveFlags.watching. Implementations typically queue the node for execution after the current write/batch completes.
-
propagate(
ReactiveLink link, [bool innerWrite = false]) → void -
Push phase: starting from
link(the subscriber list of a node that just changed), walks the graph iteratively marking subscriberspending(ordirtyvia shallowPropagate later) and calling notify on watching nodes. Recursion through mutable nodes is flattened with an explicit EngineStack.innerWritemust betruewhen the write happened inside a running effect, enabling the re-entrancy bookkeeping (ReactiveFlags.recursed). -
shallowPropagate(
ReactiveLink link) → void -
Promotes
pendingsubscribers of a node that confirmed a change todirty, notifying watchers. Non-recursive: touches immediate subscribers only. -
toString(
) → String -
A string representation of this object.
inherited
-
unlink(
ReactiveLink link, ReactiveNode sub) → ReactiveLink? -
Removes the edge
linkfrom both lists it belongs to. If the dependency side loses its last subscriber, unwatched fires. Returns the next link insub's dependency list (an iteration convenience). -
unwatched(
ReactiveNode node) → void -
Called by unlink when
nodeloses its last subscriber — the hook for automatic cleanup (release dependencies, stop work, free caches). -
update(
ReactiveNode node) → bool -
Recomputes
node's value in place and returns whether it actually changed. Returningfalsecuts propagation belownode(this is where anequalspolicy plugs in).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited