How to “yield put” in redux-saga within a callback?

前端 未结 3 1186
猫巷女王i
猫巷女王i 2020-12-30 23:56

Because \"yield\"-statement isn\'t allowed within a callback, how can i use the \"put\" feature of redux-saga within a callback?

I\'d like to have the following call

3条回答
  •  甜味超标
    2020-12-31 00:18

    Beside using channel as @Alex suggest, one might also consider using call from 'redux-saga/effects'. The call effect take a function or Promise.

    import { call } from 'redux-saga/effects';
    
    // ...
    
    yield call(download.promise);

提交回复
热议问题