willUpdate method

  1. @override
void willUpdate(
  1. ValueCell cell
)
override

The observed cell will change its value.

This method is called when the value of an ancestor of cell has been changed however the value of cell has not been recomputed.

cell.value still holds the cell's previous value.

Implementation

@override
void willUpdate(ValueCell cell) {
  if (!updating) {
    assert(_changedDependencies == 0, 'Number of changed dependencies not equal to zero at start of update cycle.\n\n'
        'This indicates that CellObserver.update() was not called on the '
        'observers of the cell, from which this error originates, during the '
        'previous update cycle\n\n'
        'This indicates a bug in Live Cells unless the error originates from a'
        'ValueCell subclass provided by a third party, in which case it indicates'
        "a bug in the third party's code."
    );

    preUpdate();

    updating = true;

    _didChange = false;
    _changedDependencies = 0;

    onWillUpdate();
  }

  _changedDependencies++;
}