redux-kefir
Kefir bindings for Redux
npm install --save redux-kefir
ReduxStore): KefirProperty
createProjection(store:Creates an observable of state over time from a Redux store.
Usage
Given store
, create a projection:
let stateProjection =
To do anything useful with the newly minted stateProjection
, we must use the Kefir API.
ReduxMiddleware
observableMiddleware:Enables dispatching Kefir observables and Flux Standard Actions that have observable payloads.
Usage
createStore = 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 Kefir
Dispatch new observable stream, mapping its values through the action creator:
store
Or dispatch an FSA that has observable payload, essentially, inverting control:
store
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.