throttle method

ReableThrottledBeacon<T> throttle(
  1. Duration duration, {
  2. bool dropBlocked = true,
  3. String? name,
})

Returns a ThrottledBeacon that wraps this Beacon.

final count = Beacon.writable(10);
final throttledCount = count.throttle(duration: k10ms);

throttledCount.value = 20; //  equivalent to count.set(20, force: true);

expect(count.value, equals(20));
expect(throttledCount.value, equals(10)); // this is 10 because the update was throttled

See: Beacon.throttled for more details.

Implementation

ReableThrottledBeacon<T> throttle(
  Duration duration, {
  bool dropBlocked = true,
  String? name,
}) {
  assert(
    this is! BufferedBaseBeacon,
    '''
Chaining of buffered beacons is not supported!
Buffered beacons has to be the last in the chain.

Good: someBeacon.filter().buffer(10);

Bad: someBeacon.buffer(10).filter();

If you absolutely need this functionality, it has to be done manually with .wrap.
eg:
final beacon = Beacon.throttled<T>(0).wrap(someBufferedBeacon)
''',
  );

  final beacon = Beacon.lazyThrottled<T>(
    duration: duration,
    dropBlocked: dropBlocked,
    name: name,
  );

  _wrapThis(beacon);

  return beacon;
}