All Projects → mercari → RxReduxK

mercari / RxReduxK

Licence: MIT license
Micro-framework for Redux implemented in Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to RxReduxK

Reatom
State manager with a focus of all needs
Stars: ✭ 567 (+772.31%)
Mutual labels:  flux, state-management, state, store
Flooks
🍸 A state manager for React Hooks
Stars: ✭ 201 (+209.23%)
Mutual labels:  flux, state, store
Deox
Functional Type-safe Flux Standard Utilities
Stars: ✭ 200 (+207.69%)
Mutual labels:  flux, reducer, action
mafuba
Simple state container for react apps.
Stars: ✭ 20 (-69.23%)
Mutual labels:  flux, state, store
vue
Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores
Stars: ✭ 25 (-61.54%)
Mutual labels:  state-management, state, store
Juicr.js
A simple (and tiny <1kb) redux inspired reducer for handling state changes.
Stars: ✭ 102 (+56.92%)
Mutual labels:  flux, state-management, reducer
redux-reducer-async
Create redux reducers for async behaviors of multiple actions.
Stars: ✭ 14 (-78.46%)
Mutual labels:  flux, reducer, action
teaful
🍵 Tiny, easy and powerful React state management
Stars: ✭ 638 (+881.54%)
Mutual labels:  state-management, state, store
okito
Your best flutter coding friend. All in one; state management, navigation management(with dynamic routing), local storage, localization, dependency injection, cool extensions with best usages and with the support of best utilities!
Stars: ✭ 37 (-43.08%)
Mutual labels:  state-management, state, store
vue-reactive-store
A VueX alternative : declarative + reactive + centralized way to structure your data store. Inspired by VueX and Vue.js . Compatible with vue-devtools.
Stars: ✭ 27 (-58.46%)
Mutual labels:  state-management, state, store
hermes-js
Universal action dispatcher for JavaScript apps
Stars: ✭ 15 (-76.92%)
Mutual labels:  flux, reducer, action
vuex-but-for-react
A state management library for React, heavily inspired by vuex
Stars: ✭ 96 (+47.69%)
Mutual labels:  flux, state-management, state
Freezer
A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
Stars: ✭ 1,268 (+1850.77%)
Mutual labels:  flux, state-management, store
Clean State
🐻 A pure and compact state manager, using React-hooks native implementation, automatically connect the module organization architecture. 🍋
Stars: ✭ 107 (+64.62%)
Mutual labels:  flux, state, reducer
Little State Machine
📠 React custom hook for persist state management
Stars: ✭ 654 (+906.15%)
Mutual labels:  flux, state-management, state
vuse-rx
Vue 3 + rxjs = ❤
Stars: ✭ 52 (-20%)
Mutual labels:  state-management, state, rx
Use Substate
🍙 Lightweight (<600B minified + gzipped) React Hook to subscribe to a subset of your single app state.
Stars: ✭ 97 (+49.23%)
Mutual labels:  state-management, store, reducer
Vue State Store
📮 VSS (Vue State Store) - Vue State Management (with Publish & Subscribe pattern)
Stars: ✭ 128 (+96.92%)
Mutual labels:  state-management, state, store
temperjs
State management for React, made simple.
Stars: ✭ 15 (-76.92%)
Mutual labels:  flux, state-management, state
mutable
State containers with dirty checking and more
Stars: ✭ 32 (-50.77%)
Mutual labels:  flux, state-management, state

RxRedux for Kotlin

jcenter Build Status

Micro-framework for Redux implemented in Kotlin

Installation

dependencies {
  repositories {
    jcenter()
  }
}

implementation("com.mercari.rxredux:rxredux:<latest-version>")

Usage

This framework is composed of several types/abstractions inspired by Redux that help to implement the reactive behavior of application components. It is based on RxJava for reactivity and works well with RemoteDataK.

State

State represents the model or state of your component or UI. A State is recommended to be immutable, however it can be allowed to be mutable.

This can typically be implemented by a data class

For example:

data class CounterState(
    val counter: Int
) : State

Action

An Action represents the desired modifications on a State, for example

class Increment : Action
class Decrement : Action

Although not required, it is recommended to model Actions as class hierarchy with a sealed class.

sealed class CounterAction : Action

class Increment : CounterAction()
class Decrement : CounterAction()

An Action can contain parameters that make them more useful depending on the desired behaviour. For example:

class Increment(val by: Int) : CounterAction

Actions are to be dispatched through the Store's dispatch method to perform State mutations.

For example:

store.dispatch(Increment(2))

Reducer

A Reducer is where the State is mutated or modified, depending on which Action is applied. It is basically a map of the desired modifications and their effects.

For example:

class CounterReducer: Reducer<CounterState, CounterAction> {
    override fun reduce(currentState: CounterState, action: CounterAction) : CounterState =
        when(action) {
          is Increment -> CounterState(counter: currenState.counter + action.by)
          is Decrement -> CounterState(counter: currenState.counter - action.by)
        }
}

Middleware

Middleware allows for a variety of behaviours that are not directly related to the component's State. This is useful for the implementation of so called cross-cutting concerns such as Logging, by hooking into the sequence of Action events.

Middleware can run before reducing the state or after depending on the need, this can be achieved by overriding the provided methods.

Store

The Store "stores" the State, and exposes it for observation as an Observable. It also connects all the other abstractions together.

To create a Store, simply instantiate it with an initial State and its related Reducer:

val counterStore = Store(initialState, reducer)

Several middleware can also be added to the Store through the Store's addMiddleware method.

Examples

Examples of usage can be seen in the tests

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].