-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
the generic type on debounce (and probably also throttle), isn't used anywhere else except the debounce.
if we move the generic type to be only on the debounce method, the same debouncer can be used for different methods.
as in my last issue #9 , I'm trying to wrap the geocode package with a debouncer so it won't call geocode more than 1 once a second. the geocode package has two methods, each of them returns a different type.
it would be nice to be able to do this:
class DebouncedGeoCode {
final GeoCode geoCode = GeoCode();
final debouncer =
Debouncing<Future<Address>>(duration: const Duration(milliseconds: 1000));
Future<Address?> reverseGeocoding(
{required double latitude, required double longitude}) async {
var response = await debouncer.debounce<Future<Address>>(() =>
geoCode.reverseGeocoding(latitude: latitude, longitude: longitude));
return await response;
}
Future<Coordinates?> forwardGeocoding({required String address}) async {
var response = await debouncer.debounce(() =>
geoCode.forwardGeocoding(address: address));
return await response;
}
}using one debouncer is preferable over two because I want to limit every request not just those of the same type
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers