applyMiddleware method

  1. @override
Stream<WareContext<T>> applyMiddleware(
  1. Stream<WareContext<T>> input
)
override

Implementation

@override
Stream<WareContext<T>> applyMiddleware(Stream<WareContext<T>> input) {
  // This rather complicated-looking statement splits the incoming stream of
  // Actions into two streams. Actions that match the types in [actionTypes]
  // go into one, and all other actions go into the other. The stream that
  // contains the matching actions is then debounced using the provided
  // Duration.
  return MergeStream<WareContext<T>>([
    input.where((c) => !actionTypes.contains(c.action.runtimeType)),
    input
        .where((c) => actionTypes.contains(c.action.runtimeType))
        .debounceTime(duration),
  ]);
}