takeEvery로 보낼 수있는 다른 요청이 UI에 의해 시작되는지는 확실하지 않습니다.이 경우 UI가 초기 데이터가로드되었는지 확인하여 UI를 비활성화해야합니다.
그러나 당신이 사가에서 얘기하는 경우,이 같은 InitialDataLoaded 행동을 기다릴 수 :
function* watchAppInit() {
while (true) {
// when this completes it dispatches the InitialDataLoaded action
yield fork(loadInitialData);
yield take(actionTypes.InitialDataLoaded);
// this won't execute until InitialDataLoaded action is dispatched
yield fork(doOtherStuff);
}
}
하거나 다른 작업 상태를 확인할 수 있습니다
function* watchDoOtherStuff() {
while (true) {
const action = yield take(actionTypes.DO_OTHER_STUFF);
// check the state to see if you have initial data
const initialized = yield select(selectors.getInitialDataLoaded);
if (initialized) {
yield fork(doIt);
}
}
}
첫 번째에게 이상적인 솔루션 – Cleiton