doBatchUpdate static method

void doBatchUpdate(
  1. VoidCallback callback
)

Executes a batched update which allows multiple updates to be batched into a single update. This can be used to optimize performance by reducing the number of update notifications.

Example:

final age = Beacon.writable<int>(10);

var callCount = 0;

age.subscribe((_) => callCount++);

Beacon.doBatchUpdate(() {
  age.value = 15;
  age.value = 16;
  age.value = 20;
  age.value = 23;
});

expect(callCount, equals(1)); // There were 4 updates, but only 1 notification

Implementation

static void doBatchUpdate(VoidCallback callback) {
  batch(callback);
}