-
-
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
Transform Example #19
Comments
Hi @rsnider19 if we use the @override
Stream<CounterState> transform(
Stream<CounterEvent> events,
Stream<CounterState> Function(CounterEvent event) next,
) {
final observableStream = events as Observable<CounterEvent>;
final nonDebounceStream = observableStream.where((event) {
return (event is! Search);
});
final debounceStream = observableStream.where((event) {
return (event is Search);
}).debounce(Duration(milliseconds: 300));
return super.transform(nonDebounceStream.mergeWith([debounceStream]), next);
} Essentially, in the transform override you have access to the raw In a simple case where you want to debounce all events you can simply do: @override
Stream<CounterState> transform(
Stream<CounterEvent> events,
Stream<CounterState> Function(CounterEvent event) next,
) {
return super.transform(
(events as Observable<CounterEvent>).debounce(
Duration(milliseconds: 300),
),
next,
);
} You can checkout the github search example app for an example of debouncing all events. Let me know if that makes sense or if you have other questions. |
Closing this for now but feel free to comment with any additional questions and I'll reopen it 👍 |
Worked perfect! Thanks! |
Can you please provide an example of overriding
transform
? Specifically debouncing a certain event (e.g. Search), but not other events in the bloc? Thanks!The text was updated successfully, but these errors were encountered: