MetaCell<T> class

A cell that points to another cell.

This cell points to another, which the value of this cell is the value of the cell it points to and the observers of this cell are notified when the value of the cell it points to changes.

The pointed to cell is set after construction and can be changed multiple times. NOTE: The observers of this cell are not notified when the pointed to cell changes.

If value is accessed before the cell, to which this cell points to, is set an EmptyMetaCellError exception is thrown. Note, also this cell must have at least one observer before setting the cell to which it points to.

Usage:

final a = MutableCell(0);
final b = MutableCell(10);

final meta = MetaCell<int>();

ValueCell.watch(() => print(meta()));

// `meta` now points to `a`
meta.setCell(a);

print(meta.value); // Prints: 0

// The following causes the watch function defiend above
// to be called

a.value = 1; // Prints: 1
a.value = 2; // Prints: 2

// `meta` now points to `b`
meta.setCell(b);

b.value = 11; // Prints: 11
b.value = 12; // Prints: 12
Inheritance
Implementers
Available extensions

Constructors

MetaCell({dynamic key})
Create a cell that points to another cell.

Properties

equalityCellFactory EqualityCellFactory
Return a factory for creating equality and inequality comparison cells.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasState bool
Does this cell have a state?
no setterinherited
key ↔ dynamic
Key which uniquely identifies the cell
latefinalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state CellState<StatefulCell>?
The current state of the cell, or null if the cell is inactive.
no setterinherited
value → T
The cell's value
no setteroverride

Methods

addObserver(CellObserver observer) → void
Register an observer of the cell to be called when the cell's value changes.
inherited
call() → T
Retrieve the value of the cell.
inherited
createState() CellState<StatefulCell>
Create the CellState for this cell.
override
eq<U>(ValueCell<U> other) ValueCell<bool>
Returns a new ValueCell which compares the value of this cell to another cell for equality.
inherited
inject(ValueCell<T> cell) → void
Alias of setCell.
neq<U>(ValueCell<U> other) ValueCell<bool>
Returns a new ValueCell which compares the value of this cell to another cell for inequality.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observe() → void
Track this cell as an argument of the current compute/watch function.
inherited
removeObserver(CellObserver observer) → void
Remove an observer that was previously registered with addObserver.
inherited
setCell(ValueCell<T> cell) → void
Set the cell to which this cell points to.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

action({dynamic key}) ActionMetaCell
Create a MetaCell that points to an ActionCell.
mutable<T>({dynamic key}) MutableMetaCell<T>
Create a MetaCell that points to a MutableCell.