DebouncedSignal<T> constructor

DebouncedSignal<T>(
  1. Signal<T> source,
  2. Duration duration, {
  3. String? debugLabel,
  4. bool equals(
    1. T a,
    2. T b
    )?,
  5. T guard(
    1. T current,
    2. T next
    )?,
  6. VoidCallback? onListen,
  7. VoidCallback? onCancel,
})

Implementation

DebouncedSignal(
  this.source,
  this.duration, {
  String? debugLabel,
  super.equals,
  super.guard,
  super.onListen,
  super.onCancel,
}) : super(source.val, debugLabel: debugLabel) {
  _subscription = source.stream.listen((value) {
    _debounceTimer?.cancel();
    _debounceTimer = Timer(duration, () {
      emit(value);
    });
  });
}