I want to paginate a ListView, so I use NotificationListener<ScrollNotification> which adds new event when the end of the ListView is reached. But I want to use debounce to get rid of spamming event about end of the ListView. So I use it in this way in the Bloc:
@override
Stream<ListState> transformEvents(
Stream<ListEvent> events,
Stream<ListState> Function(ListEvent event) next,
) {
return super.transformEvents(
events.debounceTime(
Duration(milliseconds: 500),
),
next,
);
}
But now I have three problems:
debounceTime, how can I specify which subclasses of ListEvent should has debounceTime?debounceTime should be only between two instances of the same class? Thus, for example, if this is the first event of this class, then debounceTime isn't needed.Hi @don-prog 馃憢
Thanks for opening an issue!
Have you checked out https://github.com/felangel/bloc/issues/524#issuecomment-573978217?
@felangel thanks, I think this comment solves my second question. And what about two others?
debounceTime works. Maybe you're looking for a different operator like throttle or buffer?Closing for now but feel free to comment with additional questions or details and I鈥檓 happy to continue the conversation 馃憤
@felangel sorry, I forgot to reply. throttleTime is what I need, thanks!
Most helpful comment
@felangel sorry, I forgot to reply.
throttleTimeis what I need, thanks!