debounceEvent method
BlocDebounceEventCallback<FastNavigationSplitViewBlocEvent<FastItem> >
debounceEvent(
- BlocDebounceEventCallback<
FastNavigationSplitViewBlocEvent< function, {FastItem> > - Duration delay = const Duration(milliseconds: 300),
inherited
Creates a debounced function that only invokes function
after a delay
.
For example:
final debounced = debounce((BlocEvent event) {
// heavy stuff
});
Implementation
BlocDebounceEventCallback<E> debounceEvent(
BlocDebounceEventCallback<E> function, {
Duration delay = const Duration(milliseconds: 300),
}) {
final debouncer = PublishSubject<Tuple2<BlocDebounceEventCallback<E>, E>>();
publishers.add(debouncer);
subxList.add(
debouncer
.debounceTime(delay)
.listen((Tuple2<BlocDebounceEventCallback<E>, E> tuple) {
tuple.item1(tuple.item2);
}),
);
return (E event) {
final tuple = Tuple2<BlocDebounceEventCallback<E>, E>(function, event);
debouncer.add(tuple);
};
}