Replies: 1 comment
-
I use RX for this kind of thing (in this case rxdart). RX is in my opinion a required knowledge when doing UI, and is applicable to every framework you may use. In your HookConsumerWidget, you could use something like this (untested, may not compile): Widget build(...) {
final tapStreamController = useStreamController<bool>();
useEffect(() {
final subscription = tapStreamController.stream
.debounceTime(const Duration(milliseconds: 500))
.listen((_) {
ref.read(interactionControllerProvider.notifier).interactLike();
});
return subscription.cancel;
}, [tapStreamController]);
return OutlinedButton(
onPressed: () => tapStreamController.add(true),
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, the debouncing example in the documentation is only about when the provider itself is being disposed.
I am wondering what would be the proper method to debounce this for example:
interactLike() is called by a button widget, what I want to do is that when the user tap on the button, I want to wait a few milliseconds before sending the request, if within that timeframe, the user tap again the button, no request will be sent.
Beta Was this translation helpful? Give feedback.
All reactions