derive<S> function
Derive the next value of a Signal from the previous value.
Set the next value of a Signal by reusing the previous value of the given
Signal, giving derive a reference to the signal and a function that
calculates on how to get the derivedValue. This may be used when updating
a signal that keeps track of a mutable object as its state for example.
Implementation
derive<S>(Signal<S> signal, DeriveValue<S> derivedValue) {
final (getter, setter) = signal;
setter(derivedValue(getter()));
}