3 ms·
It isn't hard to create easily testable redux actions using redux-thunk. When you configure the redux store you can use `thunk.withExtraArgument` to provide a s
by rhinoceraptor 9y ago
It isn't hard to create easily testable redux actions using redux-thunk. When you configure the redux store you can use `thunk.withExtraArgument` to provide a service object to your actions, so you can write something like this:
const getDog = dogId => (dispatch, getState, { DogApi }) => {
dispatch(fetchingDog(dogId))
DogApi.getDogById(dogId, (err, dog) => {
dispatch(err ? dogFetchError(err) : fetchedDog(dog))
})
}
...
dispatch(getDog(123))