debounce method

RxReaction debounce(
  1. Duration delay,
  2. void callback(
    1. T
    )
)

Every time that the Rx<T> changes the callback will be called after a delay.

Implementation

RxReaction debounce(Duration delay, void Function(T) callback) {
  final debouncer = Debouncer(delay);
  // ignore: cancel_subscriptions
  final StreamSubscription subscription = stream.listen((event) {
    debouncer.call(() {
      callback(event);
    });
  });
  return RxReaction(subscription, debouncer);
}