0
サンク・ミドルウェアはどこに置かれますか? 「doesnのサンク リアクションレスキューミドルウェアの流れはどのように機能しますか?
promise
値を持つ
- 派遣アクション:これは私がこの今を通過見るミドルウェアの順番ですが、私はサンクの出番にはまり込みます関数ではなくオブジェクトであるため何もしません
- はpromiseErrorMiddlewareに行きます。promiseErrorMiddlewareは
applyMiddlware
からストアを取得し、関数を返します。 - この関数は返されても、送出されていなくてもThunkによって傍受されますか?アクションを引数として次の関数を返すこの関数を正確に実行しているのは誰ですか?誰が最終的な機能を実行しますか?
ストア
const store = createStore(
rootReducer,
applyMiddleware(thunkMiddleware, promiseErrorMiddleware, dataTrafficMiddleware)
)
actionCreator
dispatch({url: requestURL, promise: true})
promiseErrorMiddleware & dataTrafficMiddleware
const promiseErrorMiddleware = function (store) { //where is store from, applyMiddleware?
return function (next) { //where is next from?
return function (action) {
if (!action.promise) {
return next(action)
} else {
return fetch(action.url).then(function (data) {
...
next({data, needDirection: true})
})
}
}
}
}
const dataTrafficMiddleware = function (store) {
return function (next) {
return function (action) {
if (!action.needDirection) {
return next(action)
} else {
//dispatch regular action with type and data
}
}
}
}
}
[なぜReduxで非同期フローのミドルウェアが必要なのですか?](http://stackoverflow.com/questions/34570758/why-do-we-need-middleware-for-async-flow-in-還元剤) – vijayst