ComputeCell<T> constructor

ComputeCell<T>({
  1. required T compute(),
  2. required Set<ValueCell> arguments,
  3. dynamic key,
})

Create a ComputeCell with a given compute function.

The compute function is called with no arguments whenever the value of the cell is accessed. It should return the cell's value.

arguments is the set of argument cells on which the value of the cell depends. The observers of this cell are notified whenever the values of the argument cells change.

Example:

final ValueCell<int> a = ...;
final ValueCell<int> b = ...;
...
// A ValueCell that computes the sum of the values of two cells
final c = ComputeCell(
   arguments: [a, b],
   compute: () => a.value + b.value
);

Implementation

ComputeCell({
  required this.compute,
  required Set<ValueCell> arguments,
  super.key,
}) : super(arguments);