mutableApply<U> method
- U fn(
- T1,
- T2,
- T3,
- T4,
- T5,
- T6,
- T7,
- void reverse(
- U
- dynamic key,
- bool changesOnly = false,
Create a MutableComputeCell with given compute and reverse compute functions, and the cells in this as the argument list.
The fn
function is called with the values of the cells in this
passed as arguments whenever the value of at least one cell in this
changes. It should return the cell's value.
The reverse
function is called when the value
of the cell is
set, with the new value passed as an argument to the function. It should
set the values of the argument cells accordingly such that calling fn
again will produce the same value that was passed to reverse
.
reverse
is called in a batch update, by MutableCell.batch, so
that the values of the argument cells are set simultaneously.
If changesOnly
is true, the returned cell only notifies its observers
if its value has actually changed.
If key
is non-null a MutableCellView identified by key
is returned.
If key
is null a MutableComputeCell is returned.
Implementation
MutableCell<U> mutableApply<U>(U Function(T1, T2, T3, T4, T5, T6, T7) fn, void Function(U) reverse, {
key,
bool changesOnly = false
}) {
if (key == null) {
return MutableComputeCell(
compute: () => fn($1.value, $2.value, $3.value, $4.value, $5.value, $6.value, $7.value),
reverseCompute: reverse,
arguments: {$1, $2, $3, $4, $5, $6, $7},
changesOnly: changesOnly
);
}
else if (changesOnly) {
return apply(fn, key: key != null ? _MutableApplyKey(this, key) : null)
.store(changesOnly: true)
.mutableApply((p0) => p0, reverse, key: key);
}
return MutableCellView(
key: key,
compute: () => fn($1.value, $2.value, $3.value, $4.value, $5.value, $6.value, $7.value),
reverse: reverse,
arguments: {$1, $2, $3, $4, $5, $6, $7},
);
}