bouncer

Creator: coderz1093

Last updated:

0 purchases

bouncer Image
bouncer Images

Languages

Categories

Add to Cart

Description:

bouncer

bouncer #
Bouncer debounces actions and makes sure any outdated answers will be ignored.
Problem statement #
When user actions lead to starting several concurrent requests to some slow resource,
there can be 2 problems:

exhausting of the resource
answers coming in random order

This library aims to solve both problems.

See example for reference.
Usage #
instead of
var response = await _longRunningRequest(parameters)
_responseHandler(response);
copied to clipboard
let's debounce:
_debounceSubscription = TimerBouncer(Duration(milliseconds: 200)).debounce(
request: () => _longRunningRequest(parameters),
responseHandler: _responseHandler,
oldSubscription: _debounceSubscription,
);
copied to clipboard
don't forget to dispose _debounceSubscription when it's no longer in use.
@override
dispose() {
_debounceSubscription?.cancel();
super.dispose();
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.