A versatile custom node computation for handling multiple inbound dependencies (N:1).
ComplexComputation manages an N:1 set of upstream dependencies declared via manifest. It automatically coordinates dirty propagation and lazy reverse-traversal computation.
Design Philosophy: Complex business logic often requires aggregating multiple data sources. ComplexComputation decouples dependency registration from calculation: manifest declares the graph connections while compute computes the combined result lazily.
Data Flow Architecture (Push-Dirty, Pull-Data):
- Push-Dirty (Downstream Propagation): When any upstream node declared in manifest becomes dirty, ComplexComputation marks itself as dirty and forwards the signal without executing compute.
- Pull-Data & Lazy Computation (Reverse Traversal): When a downstream terminal requests data, compute is invoked once per computation cycle, caching the result.
AI & Developer Note:
- Pure Function Constraint: The compute method MUST be pure and synchronous. Do not perform side-effects (e.g., UI updates, network calls) inside compute.
- Manifest Alignment: Every node accessed inside compute MUST be returned in manifest.
Example:
class SumComputation extends ComplexComputation<int> {
SumComputation(this.a, this.b);
final Coral<int> a;
final Coral<int> b;
@override
@manifestSync
Iterable<CoralNode> manifest() => [a, b];
@override
int compute() => a.data + b.data;
}
- Inheritance
-
- Object
- CoralComputation<
T> - ComplexComputation
- Implementers
- Available extensions
Constructors
Properties
-
coral
→ Coral<
T> -
Exposes the underlying topological node that powers this computation.
no setterinherited
- debugCreationLocation → String?
-
Available on CoralComputation, provided by the CoralComputationDebugExtension extension
no setter - debugTag → String?
-
Available on CoralComputation, provided by the CoralComputationDebugExtension extension
no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isActivated → bool
-
Indicates whether the underlying topological node is currently active in the graph.
no setterinherited
- isDeactivated → bool
-
Indicates whether the underlying topological node is currently deactivated.
no setterinherited
- isPaused → bool
-
Indicates whether the underlying topological node is currently in a paused state.
no setterinherited
- isRunning → bool
-
Indicates whether the underlying topological node is running and processing events.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cascade<
T> (Coral< T> cascade(S data), {bool eager = false}) → Coral<T> -
Available on CoralProvider<
Delegates CoralComputationExtension.cascade to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
compute(
) → T -
Performs the actual computation and returns the new value for this node based on the upstream dependencies.
override
-
debugTrace(
[String? tag, int traceCount = 5]) → void -
Available on CoralComputation, provided by the CoralComputationDebugExtension extension
-
distinct(
[bool equals(S previous, S next)?]) → Coral< S> -
Available on CoralProvider<
Delegates CoralComputationExtension.distinct to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
diverge<
T> (Iterable< Coral< cascade(S data), {bool seal = true, bool hotswap = false, bool eager = false}) → Trunk<T> >T> -
Available on CoralProvider<
Delegates CoralComputationExtension.diverge to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
fallback(
{S onEmpty()?, S onDamage(Object error, [StackTrace? stackTrace])?}) → Coral< S> -
Available on CoralProvider<
Delegates CoralComputationExtension.fallback to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
fallbackEmptyToNull(
) → Coral< S?> -
Available on CoralProvider<
Delegates CoralComputationExtension.fallbackEmptyToNull to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
guard(
{required bool canProceed(), Object? getReasonIfCannotProceed()?}) → Coral< S> -
Available on CoralProvider<
Delegates CoralComputationExtension.guard to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
iterateInbound(
) → Iterable< CoralNode> -
Iterates over all direct upstream inbound nodes connected to this computation.
inherited
-
manifest(
) → Iterable< CoralNode> - Declares all upstream dependencies this computation reads from for its computation.
-
map<
T> (T convert(S source)) → Coral< T> -
Available on CoralProvider<
Delegates CoralComputationExtension.map to the underlying Coral.S> , provided by the CoralProviderComputationExtension extension -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toBroadcaster(
) → CoralBroadcaster< S> -
Available on CoralProvider<
S> , provided by the CoralProviderExtension extension -
toInheritedWidget(
{Key? key, required Widget child}) → InheritedCoralProviderWidget< T> -
Available on CoralProvider<
Converts this CoralProvider into an InheritedCoralProviderWidget.T> , provided by the CoralProviderInheritedWidgetExtension extension -
toString(
) → String -
A string representation of this object.
inherited
-
toTerminal(
void onDirty()) → CoralTerminal< S> -
Available on CoralProvider<
S> , provided by the CoralProviderExtension extension -
toWidget(
{Key? key, Widget errorBuilder(BuildContext context, Object error, StackTrace? stackTrace)?}) → CoralWidget -
Available on T, provided by the CoralComputationWidgetExtension extension
Converts this Computation into a strongly-typed CoralWidget. -
toWidget(
{Key? key, Widget errorBuilder(BuildContext context, Object error, StackTrace? stackTrace)?}) → CoralWidget -
Available on CoralProvider<
Converts this CoralProvider into a CoralWidget.Widget> , provided by the CoralWidgetProviderExtension extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited