change `onDebounce` to `callback`

This commit is contained in:
krawieck 2020-09-22 13:50:54 +02:00
parent 15f408e8db
commit df4e1253b4
1 changed files with 3 additions and 5 deletions

View File

@ -9,9 +9,7 @@ class Debounce {
final bool loading;
final void Function() bounce;
call() {
bounce();
}
void call() => bounce();
const Debounce({
@required this.loading,
@ -23,7 +21,7 @@ class Debounce {
/// and loading is triggered after [delayDuration].
/// Everything can be reset with [.cancel()]
Debounce useDebounce(
Future<Null> Function() onDebounce, [
Future<Null> Function() callback, [
Duration delayDuration = const Duration(milliseconds: 500),
]) {
final loading = useState(false);
@ -37,7 +35,7 @@ Debounce useDebounce(
start() {
timerHandle.current = Timer(delayDuration, () async {
loading.value = true;
await onDebounce();
await callback();
cancel();
});
}