-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Debounce states #382
Comments
@matanshukry Can't this be achieved using something like the following example taken from the bloc's Github Search example? |
Hi @matanshukry 👋 What are your thoughts on something like this instead: BlocBuilder<CounterBloc, int>(
transformer: (state) =>
(state as Observable<int>).debounceTime(Duration(seconds: 1)),
builder: (context, count) {
return Center(
child: Text(
'$count',
style: TextStyle(fontSize: 24.0),
),
);
},
), This would allow for more flexibility like filtering the bloc state, debouncing, etc..
|
Hi @felangel , what's the difference between your suggestion above with the example from my comment above? Is it about the thing being debounced, yours is debouncing the state, and my comment's is debouncing the event? |
Hey @livingmine yup exactly 👍 |
published in |
Is your feature request related to a problem? Please describe.
Imagine the following scenario:
What will usually happen in the above scenario, is that when the user will type the first 4 letters, the user will see a circular loading progress bar quickly, and it will then disappear.
Describe the solution you'd like
I would like to debounce the state. That is, if the state
SearchStateLoading
is shown for less than 500ms, I don't want it to change at all.Something like this, possibly:
Describe alternatives you've considered
Unless there's a built-in way I'm unaware of, this feature can be implemented as a different widget. I just think it would be a nice addition to BlocBuilder, since it seems like a common use case for search widgets
Additional context
The text was updated successfully, but these errors were encountered: