News for hackers. Stuff that matters.
Re:Understanding redux-saga: From action creators to sagas by rhinoceraptor on Thursday October 12, 2017 @01:46PM (#15459755)
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))

There are no comments on this comment yet.