my_debounce 0.2.0 copy "my_debounce: ^0.2.0" to clipboard
my_debounce: ^0.2.0 copied to clipboard

Exactly what you are thinking about - debouncing a function call

example/my_debounce.dart

import '../lib/my_debounce.dart';

int value = 0;

void main() async {
  Debouncer d = Debouncer(time: Duration(milliseconds: 100));
  Function func = () {
    value += 1;
  };

  d.debounce(func);
  d.debounce(func);
  d.debounce(func);
  d.debounce(func);

  // We wait a bit before checking the result. If we pass
  // `leading = true` in the constructor our function will be called
  // in the beginning of the period so we won't need this delay here.
  await Future.delayed(Duration(milliseconds: 110));

  print(value); // 1
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Exactly what you are thinking about - debouncing a function call

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on my_debounce