An example Todo app created with built_value, redurx, and flutter_redurx.
built_value
is not required you're free to represent your State by other ways.- It is Redux-based, not a attempt to be a Redux port.
- Unnecessary rebuilds are intolerable, that is why
where
is explicitly set by who knows about the State: you! - Actions holds it's own reducers and can be Asynchronous through AsyncActions
- Middlewares can act before and after Actions, note that for
AsyncActions
it callsbeforeAction
twice, one for before async execution and other for completed async execution, but before State rebuilding (#3) - Connect is composable as any other Widget, not some class you should extend.
Note: Redurx isn't a Redux implementation! It borrows some naming conventions, but you'll see a very distinct approach to Actions and Middlewares. For a Redux port on Dart, please visit: flutter_redux.
There is no special treatment to test your Widgets, they are composed inside the Connect
like it would be on any WidgetBuilder
, but with it's sub-state instead of a context
, this sub-state can be freely mocked as simple plain-old Dart code.
These two libraries are very similar since they're both based on ReduxJS. These are the differences:
- Actions
redurx
- Actions describe how the state should changeRedux
- Actions are plain ol' Dart values, Classes or Enums. Could optionally create an Action type that describes how the state should change.
- Reducers
redurx
- No reducers! Handled inside the actions.redux
- A function that takes in the current app state and the latest action and return a new app state.
- Async code / side effects
- Use
AsyncActions
andMiddleware
to perform async work / side-effects - Use
Middleware
,redux_epics
, orredux_thunk
(very similar toAsyncActions
)
- Use
- Middleware
- Slight API differences
- Both allow you to listen for specific actions and perform work based on those actions
- Flutter integration
- Both
- Convert the latest state of the Store into a Widget
- Allow you to filter which state changes result in a Widget rebuild
flutter_redux
- currently offers a few additional utilities, such asonInit
,onDispose
andonWillChange
callbacks forStoreConverters
.
- Both
- Dependency Injection
redurx
- You can use Middlewares to inject dependencies on Actions. A good call is to use mixins so you can type-safely call setter injectors. That is how we makeFetchTodos
action aware aboutTodosRepository
.redux
- Instantiate all Middleware with their dependencies when they're created