https://github.com/reloni/rxdataflow
Unidirectional Data Flow in Swift - Inspired by ReSwift
https://github.com/reloni/rxdataflow
reactive rxswift swift unidirectional
Last synced: over 1 year ago
JSON representation
Unidirectional Data Flow in Swift - Inspired by ReSwift
- Host: GitHub
- URL: https://github.com/reloni/rxdataflow
- Owner: reloni
- License: mit
- Created: 2016-11-02T18:34:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-03-20T15:35:33.000Z (about 5 years ago)
- Last Synced: 2025-01-10T08:08:22.779Z (over 1 year ago)
- Topics: reactive, rxswift, swift, unidirectional
- Language: Swift
- Homepage:
- Size: 479 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
# RxDataFlow
[](https://app.bitrise.io/app/adcbf5bae5c5640f)
[](https://codecov.io/gh/reloni/RxDataFlow)

[](https://github.com/Carthage/Carthage)
[](https://codebeat.co/projects/github-com-reloni-rxdataflow-master)
## Introduction
RxDataFlow is another implementation of unidirectional data flow architecture. This library is inspired by ReSwift (which was inspired by Redux).
More information will be added soon:)
## Components
- State: A data structure that describes state of application.
- Reducer: A pure function that creates new state on base on action and current state.
- Action: Actions describe state change. Reducer produce state changes according to dispatched action.

1. The `View Controller/View Model` creates an `Action` and dispatch it to the `FlowController`.
2. The `FlowController` switches to appropriate scheduler and sends the `State` and `Action` to the `Reducer`.
3. The `Reducer` receives the current `App State` and the dispatched `Action`, computes and returns new `State`.
4. The `FlowController` saves new `State` and sends it to the subscribers.
- In case of an error `FlowController` doesn't change `State` and sends `Error` to all subscribers instead.
- It's possible to setup special `FallbackAction` that will be dispatched in case of an error (see CompositeAction).
5. Subscriber receives new `State` and operate accordingly: `View Model` may transform `State`, `View Controller` may directly bind data to the UI.
## Dispatch rules
`FlowController` dispatches actions in internal `SerialDispatchQueueScheduler` (so all operations are asynchronous by default), all incoming actions first get in the queue and dispatches (`Reducer` get executed with current `State` and `Action` instances) one after another. For example if you dispatches three actions and every action requires network request - requests will not get fired simultaneously, but one after another.

## Dependencies
- [RxSwift](https://github.com/ReactiveX/RxSwift) >= 5.0.1
## Requirements
- Xcode 10.0
- Swift 5.0
## Installation
- Using [Carthage](https://github.com/Carthage/Carthage)
```
github "reloni/RxDataFlow"
```
## Example Projects
[SimpleToDo](https://github.com/reloni/SimpleTodo) - kind of "real world" app using this architecture, already in app store.
## Credits
List of similar projects:
- [ReSwift](https://github.com/ReSwift/ReSwift)
- [ReactorKit](https://github.com/ReactorKit/ReactorKit)
- [RxState](https://github.com/RxSwiftCommunity/RxState)