나는 async await
을 지원하는 TypeScript 2.1
과 함께 작업을 보내려면 redux-actions과 redux-promise-middleware을 사용합니다.chaining redux-actions 및 redux-promise-middleware
이 모두 redux-actions
및 redux-promise-middleware
// create an async action
const fooAction = createAction('FOO', async() => {
const { response } = await asyncFoo();
return response;
});
// use async action
fooAction('123')
를 사용하여 작업입니다 그리고 이것은 단지 redux-promise-middleware
const foo =() => dispatch => {
return dispatch({
type: 'TYPE',
payload: new Promise()
})
.then(() => dispatch(bar()));
}
어떻게 체인 redux-promise-middleware
에서이 redux-actions
와 함께 사용할 수 있습니다 사용, 액션 체인의 예입니다?
, 나는 REDUX-사가로 전환. redux-thunk의 문제점은 액션에 매개 변수로서 점점 더 많은 데이터를 전송해야하고, 결국에는 애플리케이션의 전체 상태를 거기로 옮기고 싶다는 것입니다. Redux-saga는 기본적으로 이것을 알고 있으며 이것과 다른 유용한 것들을위한 특별한 방법을 가지고 있습니다. –