Skip to content
pubscout

redux_epics

0.15.2, released 2 years ago by an unverified publisher

Middleware for Redux that handles async side effects using Dart Streams

WASM-ready
$ flutter pub add redux_epics
Source repository

What it does

redux_epics lets you write Epics—functions that transform streams of actions into new actions—making complex async logic like debouncing, cancellation, and combining streams easier. It integrates with RxDart for advanced stream operators.

AI-written summary of version 0.15.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • complex async flows needing debouncing or cancellation
  • combining multiple independent async streams
  • you already use Redux and want a typed, stream‑based middleware

Skip it when

  • simple async calls that fit a thunk
  • you prefer a different state‑management solution like Bloc or Riverpod

Strengths

  • stream‑based API for powerful async patterns
  • TypedEpic and RxDart helpers reduce boilerplate
  • combineEpics makes large epics modular
  • null‑safety and recent RxDart support

Weaknesses

  • requires Redux, which is less common in Flutter
  • learning curve for Streams and RxDart
  • not as feature‑rich as Bloc for UI state

Setup

Kind
Pure Dart
Effort
Medium
Code generation
No
Direct dependencies
2

Add dependency, import redux_epics, create EpicMiddleware, add to Store middleware list. No special permissions or build_runner needed.

import 'package:redux_epics/redux_epics.dart';

Stream<dynamic> exampleEpic(Stream<dynamic> actions, EpicStore<State> store) {
  return actions
    .where((action) => action is PerformSearchAction)
    .asyncMap((action) => api.search((action as PerformSearchAction).searchTerm)
      .then((results) => SearchResultsAction(results))
      .catchError((error) => SearchErrorAction(error)));
}

var epicMiddleware = EpicMiddleware(exampleEpic);
var store = Store<State>(reducer, middleware: [epicMiddleware]);

Alternatives

Packages that do the same job and could replace redux_epics.

  • redux_thunk

    Handles simple async actions without Streams; easier for straightforward async logic

Works with

Packages commonly used together with redux_epics: ones it builds on, ones built on it, and its own family.