redux-kefir

0.1.8 • Public • Published

redux-kefir

Kefir bindings for Redux

Test Coverage Build Status

npm install --save redux-kefir

createProjection(store: ReduxStore): KefirProperty

Creates an observable of state over time from a Redux store.

import { createProjection } from 'redux-kefir'

Usage

Given store, create a projection:

let stateProjection = createProjection(store)

To do anything useful with the newly minted stateProjection, we must use the Kefir API.


observableMiddleware: ReduxMiddleware

Enables dispatching Kefir observables and Flux Standard Actions that have observable payloads.

import { observableMiddleware } from 'redux-kefir'

Usage

createStore = applyMiddleware(observableMiddleware)(createStore)

Given a store and an action creator count(payload: number): FSA, dispatch a stream of count actions. For clarity and DRY, we'll define a stream creator obs:

let obs = () => Kefir.sequentially(50, [1,2,3])

Dispatch new observable stream, mapping its values through the action creator:

store.dispatch(obs().map(count))

Or dispatch an FSA that has observable payload, essentially, inverting control:

store.dispatch(count(obs()))

Both examples have the same outcome:

at t + 0.05s dispatched {type: "count", payload: 1},
at t + 0.10s dispatched {type: "count", payload: 2},
at t + 0.15s dispatched {type: "count", payload: 3},
then ended.

Dependencies (1)

Dev Dependencies (18)

Package Sidebar

Install

npm i redux-kefir

Weekly Downloads

0

Version

0.1.8

License

MIT

Last publish

Collaborators

  • rvikmanis