/ReduxAndroid

State management library for Presentation Layer in Android application. Inspired by JS implementation of Redux.

Primary LanguageKotlin

This library is heavily inspired by Javascript implementation of Redux: https://github.com/reactjs/redux.

Alt text

The library is intended to be used in Presentation layer of the application. Presenters shouldn't be talking to the IO devices such as Database or Network directly, but should use abstract interfaces to access data. Any change to the State will be accessible form any part of the app.

1. Description.

Library is based on unidirectional data flow. All the visual State of the application is stored in the Store. State can be modified only via Actions. State is an immutable object, so any time we make change to it we need to create new one by reducing it.

1.1. Elements of the library.

  • Store - contains the visual State of the application represented by ViewModels. Via Reducer it reduces the actions and triggers the update event via reactive streams to any Presenter binded.
  • Reducer - responsible for creating new state based on current state and passed action.
  • Action - simple object which contains type of action and state to be updated.
  • Presenter - creates the actions and dispatches them in the Store. It interacts with the View receiving interactions and updating it based on current application State. This is the place where the layer below should be called to interact with IO devices such as database, network etc.

2. Usage.

Sample usage can be found in the app module. It is an Android app using Dagger as a Dependency Injection framework. https://github.com/ktalanda/ReduxAndroid/tree/master/app/src/main/java/pl/k2net/ktalanda/maroubrascanner.

https://github.com/ktalanda/ReduxAndroid/blob/master/app/src/main/java/pl/k2net/ktalanda/maroubrascanner/main/MainPresenter.kt

License

MIT