update method

void update(
  1. T fn(
    1. T current
    )
)

Updates the value using a transformation function.

Example:

counter.update((v) => v + 1);

Implementation

void update(T Function(T current) fn) {
  value = fn(value);
}