-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I discovered some strange behaviour with the 1.1.0 release. When dispatching actions within promises the resulting order is no longer correct (or actions are missing). The problem seems to be caused by the use of setImmediate/setTimeout.
I tried to replicate this behaviour in the following test (works with 1.0.1 fails for 1.1.0):
import test from 'ava'
import { createStore, applyMiddleware } from 'redux'
import actionBuffer from '../index'
test('buffers async actions in correct order', t => {
const actionHistory = []
const store = createStore(
(state, action) => {
if (action.type.indexOf('@@') !== 0) actionHistory.push(action)
return {}
},
null,
applyMiddleware(actionBuffer('BREAKER'))
)
const action1 = {type: 'ACTION1'}
const action2 = {type: 'ACTION2'}
const breaker = {type: 'BREAKER'}
store.dispatch(action1)
return new Promise(resolve => {
store.dispatch(breaker)
store.dispatch(action2)
resolve()
}).then(() => {
t.is(actionHistory[0], breaker)
t.is(actionHistory[1], action1)
t.is(actionHistory[2], action2)
})
})Metadata
Metadata
Assignees
Labels
No labels