1.0.4 • Published 8 years ago

redux-saga-combine-latest v1.0.4

Weekly downloads
67
License
MIT
Repository
github
Last release
8 years ago

###Install

npm install --save redux-saga-combine-latest

###Usage

import { createStore, applyMiddleware } from 'redux'
import createSagaMiddleware from 'redux-saga'
import * as effects from 'redux-saga/effects'
import 'babel-polyfill'

import createCombineLatest from 'redux-saga-combine-latest'

const combineLatest = createCombineLatest(effects)

function* handleActions(actions) {
  console.log(actions)
}

function* saga() {
  yield combineLatest(['type1', 'type2'], handleActions)
}

const sagaMiddleware = createSagaMiddleware(saga)

const store = createStore(
  (state) => state,
  applyMiddleware(sagaMiddleware)
)

store.dispatch({ type: 'type1', some: 'payload' })  //nothing logged
store.dispatch({ type: 'type2', some: 'payload' })  //logs out "[{ type: 'type1', some: 'payload' }, { type: 'type2', some: 'payload' }]"
store.dispatch({ type: 'type2', other: 'payload' })  //logs out "[{ type: 'type1', some: 'payload' }, { type: 'type2', other: 'payload' }]"

Notice that the handler saga does not get invoked until at least one action of each type as been received. From that point on, each time a new action is received that we care about, the handler is invoked with the latest action of each type.

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.1

8 years ago