CoreComputed<T> class

Pure-Dart derived-value engine: the same lazy/memoized, glitch-free tracking behind Computed, without any dependency on package:flutter — no ValueListenable, no kDebugMode-gated console logging. Usable from a CLI/server context via package:all_observer/core.dart.

Computed<T> (in the main all_observer.dart barrel) wraps a CoreComputed and layers ValueListenable<T> plus the colored debug -console dispose logging on top for Flutter apps.

Since engine v2 (Fase 2), dependency tracking and invalidation run on the public ReactiveEngine graph (package:all_observer/engine.dart) instead of per-recompute registry subscriptions:

  • dependencies are intrusive engine links, reused in place across recomputes (zero allocation when the read set doesn't change);
  • invalidation is push-pull: writes only mark this computed stale through the engine graph, and an internal engine watcher (created on first evaluation, kept until close) pulls the fresh value in phase 2 of the same two-phase BatchScope flush as always — so the observable timing (addListener/listen/Observer, eager settling per flush) is unchanged;
  • a read that lands between marking and settling resolves lazily on the spot (checkDirty), which is also what heals ordering in deep cascades.

The equals filter, lazy first compute, memoization, inspector events and ObserverCycleError guards all behave as documented on Computed.

Contêiner de valor derivado em Dart puro: o mesmo rastreamento preguiçoso/memoizado e livre de glitch por trás de Computed, sem nenhuma dependência de package:flutter. Desde o motor v2 (Fase 2), o rastreamento de dependências e a invalidação rodam no grafo público ReactiveEngine (package:all_observer/engine.dart): dependências são links intrusivos reusados entre recomputações, e a invalidação é push-pull: escritas só marcam obsolescência pelo grafo do motor, e um watcher interno (criado na primeira avaliação, mantido até o close) puxa o valor fresco na fase 2 do mesmo flush em duas fases do BatchScope de sempre — preservando o timing observável de addListener/listen/Observer. Uma leitura entre a marcação e a estabilização se resolve preguiçosamente na hora (checkDirty).

Constructors

CoreComputed(T _compute(), {String? name, bool equals(T a, T b)?})
Creates a CoreComputed that derives its value by running compute. See Computed's constructor for the meaning of name and equals — identical here. compute does not run until value is first read.

Properties

hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Whether close has already been called.
no setter
label String
Stable debug label used in inspector events: name, if given, otherwise a short hash-based fallback.
no setter
registry ListenerRegistry
The listener registry backing this CoreComputed. Exposed mainly for the Flutter Computed wrapper (e.g. to count listeners on dispose).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
Reads the current value, computing it lazily on first read and registering it as a dependency of whatever tracking context is currently active — an Observer/effect (via this computed's registry) or another recomputing CoreComputed (via the engine graph). See Computed.value for the full diamond-glitch note — identical here.
no setter

Methods

addListener(ObserverVoidCallback listener) → void
Adds a raw listener. Exposed mainly for the Flutter ValueListenable adapter.
close() → void
Disposes this CoreComputed: releases every engine dependency, stops the internal watcher and clears its own listeners. Safe to call more than once.
listen(void callback(T value)) ObservableSubscription
Subscribes callback to future recomputed values, mirroring Observable.listen.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeListener(ObserverVoidCallback listener) → void
Removes a listener added via addListener.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited