EffectCell<T> class
A cell used for running side effects and observing the result.
This cell evaluates to the value of its argument cell argCell while making the following guarantees:
-
The value of argCell is only referenced when it notifies this cell that its value has changed.
-
The value of argCell is referenced at most once per value change notification.
This allows a side effect to be placed in the value computation function of the argument cell, since it is guaranteed that the side effect will only be run when triggered by the dependency cells, and will not be run more than necessary.
The result of the side effect can be observed by observing this cell.
NOTE: Accessing the value results in an UninitializeCellError
being
thrown until the first value change notification. This exception is also
thrown when value is accessed while this cell is inactive.
IMPORTANT: These guarantees hold if the argument cell only calls its computation function when its value is referenced. If the argument cell calls its computation function even when its value is not referenced, then these guarantees no longer hold.
It should also be noted that these guarantees hold only when interacting with this cell via the cell returned by this method.
- Inheritance
-
- Object
- ValueCell<
T> - StatefulCell<
T> - StoreCell<
T> - EffectCell
- Available extensions
- ActionCellEffectExtension
- ActionCellExtension
- BoolCellExtension
- BoolValueChangeExtension
- CellHolderExtension
- ComputeArgumentsTracker
- ComputeExtension
- DelayCellExtension
- DurationCellExtension
- EffectCellExtension
- ErrorCellExtension
- IterableCellExtension
- ListCellExtension
- MapCellExtension
- MaybeCellExtension
- NullCheckExtension
- NumericExtension
- PeekCellExtension
- PrevValueCellExtension
- SetCellExtension
- StoreCellExtension
- TransformExtension
- ValueChangeExtension
- WaitCellExtension
Constructors
-
EffectCell(ValueCell<
T> argCell) - Create a "side effect" cell for a given argument cell.
Properties
-
argCell
→ ValueCell<
T> -
The observed cell
finalinherited
- changesOnly → bool
-
Should the observers only be notified if this cell's value has changed?
finalinherited
- 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
→ StoreCellState<
T> ? -
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
-
dumpState(
CellValueCoder coder) → Object? -
Dump the state of the cell to a value.
inherited
-
eq<
U> (ValueCell< U> other) → ValueCell<bool> -
Returns a new ValueCell which compares the value of this cell to another cell for equality.
inherited
-
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
-
restoreState(
Object? state, CellValueCoder coder) → void -
Restore the state of the cell.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited