R
R
Roman Aleksandrovich2018-06-06 14:37:08
React
Roman Aleksandrovich, 2018-06-06 14:37:08

Redux-saga yield all not waiting for requests to complete?

Good afternoon
I use redux saga and I have a problem

fromServer.map(function (el) {
                            switch (el.type) {
                                case 'refresh_notice':
                                    effects.push(call(notice, NOTICE.notice(false, true)))
                                    break;
                                case 'refresh_pays':
                                    effects.push(call(pays, PAYS.pays(false, true)))
                                    break;
                                case 'refresh_trans':
                                    effects.push(call(transRefresh, TRANS.transRefresh(
                                        el.oid,
                                        false,
                                        true
                                    )))
                                    break;
                                case 'refresh_main':
                                    effects.push(call(main, MAIN.main(false, true)))
                                    effects.push(call(statistic, STATIC.statistic(false, true)))
                                    break;
                                default:
                                    break;
                            }
                        }
                    )
const results = yield all(...effects)
yield put.resolve({type: 'LOAD_END', payload: {results}})

how to make it so that all would wait for the response of all methods and LOAD_END was at the very end of the dispatches

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-06-06
@RomReed

Try like this:

yield all(effects)
yield put({type: 'LOAD_END', payload: {results} })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question