mutableApply<U> method
MutableCell<U>
mutableApply<U>(
- U fn(
- T
- void reverse(
- U
- dynamic key,
- bool changesOnly = false,
Create a new mutable cell, with a value that is a function of this cell's value.
The value of the returned cell is computed by fn
, which is applied on
the value of this cell. The reverse
function is called when the value
of the return cell is set. It should set the value of this cell accordingly
such that calling fn
again will produce the same value that was passed to
reverse
.
If changesOnly
is true, the returned cell only notifies its observers
if its value has actually changed.
The returned cell is identified by key
if non-null. NOTE: A key
argument is accepted since a MutableCellView is returned rather than
a full mutable computed cell.
Implementation
MutableCell<U> mutableApply<U>(U Function(T) fn, void Function(U) reverse, {
key,
bool changesOnly = false
}) {
if (changesOnly) {
return apply(fn, key: key != null ? _MutableApplyKey(this, key) : null)
.store(changesOnly: true)
.mutableApply((p0) => p0, reverse, key: key);
}
return MutableCellView(
arguments: {this},
compute: () => fn(value),
reverse: reverse,
key: key,
);
}