Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leocavalcante/ReduRx
👌 A thin layer of a Redux-based state manager on top of RxDart
https://github.com/leocavalcante/ReduRx
dart redux state-management
Last synced: about 2 months ago
JSON representation
👌 A thin layer of a Redux-based state manager on top of RxDart
- Host: GitHub
- URL: https://github.com/leocavalcante/ReduRx
- Owner: leocavalcante
- License: bsd-3-clause
- Archived: true
- Created: 2018-07-27T00:17:40.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-18T03:38:38.000Z (almost 6 years ago)
- Last Synced: 2024-10-01T09:19:00.306Z (3 months ago)
- Topics: dart, redux, state-management
- Language: Dart
- Homepage:
- Size: 17.6 KB
- Stars: 41
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Please, check out: https://github.com/leocavalcante/observable_state
--# ReduRx [![Build Status](https://travis-ci.org/leocavalcante/ReduRx.svg?branch=master)](https://travis-ci.org/leocavalcante/ReduRx)
👌 A thin layer of a Redux-based state manager on top of RxDart.[Flutter bindings](https://github.com/leocavalcante/Flutter-ReduRx) • [React bindings](https://github.com/leocavalcante/React-ReduRx)
## Getting started
* [Tutorial: Handling State in Flutter with ReduRx](https://medium.com/@leocavalcante/tutorial-handling-state-in-flutter-with-redurx-b4d50c647e4a)## Usage
```dart
import 'dart:async';
import 'package:redurx/redurx.dart';class State {
State(this.count);
final int count;@override
String toString() => count.toString();
}class Increment extends Action {
Increment([this.by = 1]);
final int by;
State reduce(State state) => State(state.count + by);
}class AsyncIncrement extends AsyncAction {
@override
Future> reduce(State state) async {
int result = await doAsyncTask();
return (State state) =>
State(count: state.count + result);
}
}
}void main() {
final store = Store(State(0));store.add(LogMiddleware());
print(store.state.count); // 0store.dispatch(Increment());
// Before action: Increment: 0 (from LogMiddleware)
// After action: Increment: 1 (from LogMiddleware)
print(store.state.count); // 1store.dispatch(Increment(2));
// Before action: Increment: 1 (from LogMiddleware)
// After action: Increment: 3 (from LogMiddleware)
print(store.state.count); // 3
}
```---
Just give it a try. Feel free to open Issues and PRs!