3 ms·
One key advantage of redux-saga is testability-- since sagas are essentially functions with their arguments passed in by the saga middleware, it is easy to inje
by willriker 9y ago
One key advantage of redux-saga is testability-- since sagas are essentially functions with their arguments passed in by the saga middleware, it is easy to inject mocked dependencies in a test environment.
- rhinoceraptor 9y agoIt 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))