throttled<T> static method

ThrottledBeacon<T> throttled<T>(
  1. T? initialValue, {
  2. required Duration duration,
})

Creates a ThrottledBeacon with an initial value and a throttle duration. This beacon limits the rate of updates to its value based on the duration. Updates that occur faster than the throttle duration are ignored.

Example:

var age = Beacon.throttled(10, duration: Duration(seconds: 1));
age.value = 20; // Update is throttled
print(age.value); // Outputs: 10
await Future.delayed(Duration(seconds: 1));
print(age.value); // Outputs: 10 because the update was ignored

Implementation

static ThrottledBeacon<T> throttled<T>(
  T? initialValue, {
  required Duration duration,
}) =>
    ThrottledBeacon<T>(initialValue: initialValue, duration: duration);