Comments (17)
@danielfpedro check out #524 (comment)
Appreciate!
from bloc.
@danielfpedro check out #524 (comment)
from bloc.
The Observable is replaced by Stream in the latest RXDart version.
@override Stream<GithubSearchState> transformEvents( Stream<GithubSearchEvent> events, Stream<GithubSearchState> Function(GithubSearchEvent event) next, ) { return (events as Observable<GithubSearchEvent>) .debounceTime( Duration(milliseconds: 300), ) .switchMap(next); }
Doesnt work as it doesnt override transformEvents().
Any input about how it can be done now?
Never mind, understood it now.
If any one comes looking for it, here's how its done now:
@override
Stream<Transition< GithubSearchEvent, GithubSearchState >> transformEvents(
Stream< GithubSearchEvent > events, transitionFn) {
return events
.debounceTime(const Duration(milliseconds: 500))
.switchMap((transitionFn));
}
from bloc.
No problem :) Glad I could help!
from bloc.
Hi @Greatcallie π
Have a look at an example here #1107 (comment)
Thanks. debounceTime wasn't recognised until i added rxdart
from bloc.
@m7mdra thanks for the video! Have you tried debouncing because it seems like the problem is your app is spamming the api on every text change.
// Add this to top with imports
import 'package:rxdart/rxdart.dart';
// Add this to your Bloc
@override
Stream<SearchEvent> transform(Stream<SearchEvent> events) {
return (events as Observable<SearchEvent>)
.debounce(Duration(milliseconds: 500));
}
Let me know if that helps.
from bloc.
@felangel yes its working now. thanks for your time.
from bloc.
Hi @antonygunawan94 π
Check out
from bloc.
Hi @Greatcallie π
Have a look at an example here #1107 (comment)
from bloc.
Is it still possible to use the debounce with flutter_bloc (7.0.1) ?
is there any solution without the import 'package:rxdart/rxdart.dart' ?
from bloc.
Thanks for opening an issue. Can you please be a bit more specific about what you expected as opposed to what you observed?
Transitions occur after a state change but before the blocβs state is updated. The reason there is a delay is because your code is dependent on a network request so the transition wonβt occur until after the github api responds with data for the success state.
Does that help?
from bloc.
@felangel
sorry if i made myself unclear since english is not native tongue.
perhaps this video might explain what im getting at: link
from bloc.
hello,
can you provide updated example on how to debounce event?
because I can't seem to find this override function in the latest flutter bloc
@override Stream<SearchEvent> transform(Stream<SearchEvent> events) { return (events as Observable<SearchEvent>) .debounce(Duration(milliseconds: 500)); }
thank you
from bloc.
@m7mdra thanks for the video! Have you tried debouncing because it seems like the problem is your app is spamming the api on every text change.
// Add this to top with imports import 'package:rxdart/rxdart.dart'; // Add this to your Bloc @override Stream<SearchEvent> transform(Stream<SearchEvent> events) { return (events as Observable<SearchEvent>) .debounce(Duration(milliseconds: 500)); }Let me know if that helps.
What if I have several events on the bloc, all events will be debounced? How to debounce just the event that fetch data from server?
from bloc.
@m7mdra thanks for the video! Have you tried debouncing because it seems like the problem is your app is spamming the api on every text change.
// Add this to top with imports import 'package:rxdart/rxdart.dart'; // Add this to your Bloc @override Stream<SearchEvent> transform(Stream<SearchEvent> events) { return (events as Observable<SearchEvent>) .debounce(Duration(milliseconds: 500)); }Let me know if that helps.
this doesn't work anymore. Please how do I do it now with the latest library?
from bloc.
The Observable is replaced by Stream in the latest RXDart version.
@override
Stream<GithubSearchState> transformEvents(
Stream<GithubSearchEvent> events,
Stream<GithubSearchState> Function(GithubSearchEvent event) next,
) {
return (events as Observable<GithubSearchEvent>)
.debounceTime(
Duration(milliseconds: 300),
)
.switchMap(next);
}
Doesnt work as it doesnt override transformEvents().
Any input about how it can be done now?
from bloc.
Is it still possible to use the debounce with flutter_bloc (7.0.1) ?
is there any solution without the import 'package:rxdart/rxdart.dart' ?
Yup you can still use debounce in 7.0.1. The easiest way is to use rxdart
π
from bloc.
Related Issues (20)
- fix: States of Different instances of the same bloc are interfering
- docs: BlocListener example loss a "," HOT 1
- chore: refactoring to `bloc` advices needed HOT 4
- fix: Bloc not calling while calling event with cascade in BlocProvider. But working fine if assigned to a variable and passed to BlocProvider. HOT 1
- fix: expected: [<States>], actual [] when unit testing landing page cubit HOT 4
- Bad state: Cannot emit new states after calling close HOT 2
- State not update when adding a new item to the list HOT 1
- question: Is it a good practice to use "business" bloc HOT 4
- docs: replay bloc with multi bloc HOT 2
- fix: MultiBlocProvider and easy_localization library problem HOT 2
- docs: Add zh-cn translation for Bloc Concepts page HOT 1
- fix: transformer works incorrectly while registering each event separately HOT 2
- feat: Make hydrated_storage.dart:Storage.read() method async
- BlocBuilder widget not rebuilding the ui on certain states. HOT 6
- question: How do I design the architecture of A very complex desktop app HOT 3
- feat(bloc)!: add support for strongly typed errors on `Emitter.onEach`/`Emitter.forEach` HOT 2
- feat(bloc): add support for optional `StackTrace` on error handlers for `Emitter.onEach`/`Emitter.forEach` HOT 2
- feat: Add `force` to Emitter HOT 7
- feat: Privacy manifest file for iOS is missing HOT 4
- question: BlocObserver and Injectable Singletons HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bloc.