A library to easily apply a unidirectional dataflow in your apps with RxJS.
Switch branches/tags
greenkeeper/ava-0.23.0 greenkeeper/ava-0.24.0 greenkeeper/ava-0.25.0 greenkeeper/ava-1.0.1 greenkeeper/browserify-16.0.0 greenkeeper/browserify-16.1.0 greenkeeper/browserify-16.1.1 greenkeeper/browserify-16.2.0 greenkeeper/browserify-16.2.1 greenkeeper/browserify-16.2.2 greenkeeper/browserify-16.2.3 greenkeeper/microbundle-0.6.0 greenkeeper/microbundle-0.7.0 greenkeeper/microbundle-0.8.0 greenkeeper/microbundle-0.8.1 greenkeeper/microbundle-0.8.2 greenkeeper/microbundle-0.8.3 greenkeeper/npm-run-all-4.1.4 greenkeeper/npm-run-all-4.1.5 greenkeeper/npm-run-all-pin-4.1.3 greenkeeper/rollup-0.57.0 greenkeeper/rollup-0.57.1 greenkeeper/rollup-0.58.0 greenkeeper/rollup-0.58.1 greenkeeper/rollup-0.58.2 greenkeeper/rollup-0.59.0 greenkeeper/rollup-0.59.1 greenkeeper/rollup-0.59.2 greenkeeper/rollup-0.59.3 greenkeeper/rollup-0.59.4 greenkeeper/rollup-0.60.0 greenkeeper/rollup-0.60.1 greenkeeper/rollup-0.60.2 greenkeeper/rollup-0.60.3 greenkeeper/rollup-0.60.4 greenkeeper/rollup-0.60.5 greenkeeper/rollup-0.60.6 greenkeeper/rollup-0.60.7 greenkeeper/rollup-0.61.0 greenkeeper/rollup-0.61.1 greenkeeper/rollup-0.61.2 greenkeeper/rollup-0.62.0 greenkeeper/rollup-0.63.0 greenkeeper/rollup-0.63.1 greenkeeper/rollup-0.63.2 greenkeeper/rollup-0.63.3 greenkeeper/rollup-0.63.4 greenkeeper/rollup-0.63.5 greenkeeper/rollup-0.64.0 greenkeeper/rollup-0.64.1 greenkeeper/rollup-0.65.0 greenkeeper/rollup-0.65.1 greenkeeper/rollup-0.65.2 greenkeeper/rollup-0.66.0 greenkeeper/rollup-0.66.1 greenkeeper/rollup-0.66.2 greenkeeper/rollup-0.66.3 greenkeeper/rollup-0.66.4 greenkeeper/rollup-0.66.5 greenkeeper/rollup-0.66.6 greenkeeper/rollup-0.67.0 greenkeeper/rollup-0.67.1 greenkeeper/rollup-0.67.2 greenkeeper/rollup-0.67.3 greenkeeper/rollup-0.67.4 greenkeeper/rollup-0.68.0 greenkeeper/@types/node-10.12.9 greenkeeper/@types/node-10.12.10 greenkeeper/@types/node-10.12.11 greenkeeper/@types/node-10.12.12 greenkeeper/@types/node-10.12.13 greenkeeper/@types/node-10.12.14 greenkeeper/@types/node-10.12.15 greenkeeper/@types/node-pin-10.12.8 greenkeeper/update-to-node-10 greenkeeper/webpack-4.26.0 greenkeeper/webpack-4.26.1 greenkeeper/webpack-4.27.0 greenkeeper/webpack-4.27.1 greenkeeper/webpack-pin-4.25.1 master next
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


FlowState 🌊

Dead simple Redux and redux-observable library built with RxJS streams. This is an easy way to introduce a stream-based unidirectional dataflow into your app.


  • Inspired by Redux and redux-observable
  • The state is delivered with streams
  • Reducers are just functions, no switch-case
  • Isolate side effects that map back to actions


npm install @kahlil/flow-state


import { createFlowState } from '@kahlil/flow-state';

const flowState = createFlowState();

Dispatch Actions

In your components dispatch actions by passing the action constant and optionally an action payload. The payload can be any value.

flowState.dispatch({ type: 'SOME_ACTION', payload: { some: 'state' } });

Create A State Stream Based On Reducers

In a file that you could call Store, create and expose state streams for your components by passing the respective reducers.

Here is also the place where you can combine state streams if they depend on one another.

// A collection of reducers.
const itemListReducers = {
  deleteItem: (action, state) => state
    .filter(item => state.filter(item.id !== action.payload.id)),
  addItem: (action, state) => [...state, action.payload],
  // ...

itemListState$ = flowState.createState$(itemListReducers, initialState);

In your component you can now subscribe to the component state stream:

itemListState$.subscribe(state => console.log(state));

Trigger Side Effects

You can trigger your side effects similar to redux-observable by listening to the actions stream, triggering your side effect and return a new action.

Each side effect is a function and has to be passed to flowState.runSideEffects.

The action that the result of each side effect maps to

// An imaginary API.
const serverApi = new serverApi();
const action$ = flowState.getAction$();

const sideEffect1 = action$ => action$
  .filter(action => action.type === 'DELETE_ITEM')
  .switchMap(action => serverApi.deleteItem(action.payload))
  .map(response => ({ type: 'RECEIVE_ITEMS', payload: response }))
  .catch(response => ({ type: 'DELETE_ITEM_ERROR', payload: response.error });

const sideEffect1 = action$ => action$
  .filter(action => action.type === 'ADD_ITEM')
  .switchMap(action => serverApi.addItem(action.payload))
  .map(response => ({ type: 'RECEIVE_ITEMS', payload: response }))
  .catch(response => ({ type: 'ADD_ITEM_ERROR', payload: response.error });

flowState.runSideEffects(sideEffect1, sideEffect2);


MIT © Kahlil Lechelt