How can I find out when the regression saga function is completed in the call code

React, redux, redux saga

I sent the action, let's say CREATE_REQUESTEDto the store. The Redux saga starts and issues an asynchronous call to the server. After the completion of the saga, i.e. Blocks for the next CREATE_REQUESTED, I want to execute additional code from the container / component from which the first was initiated CREATE_REQUESTED.

// pseudo code
class Cmp extends React.component {
   onCreateClick(id) {
     const record = {id, name: 'alabala'}
     // I am missing the .then() part
     this.props.dispatch({type: 'CREATE_REQUESTED', record}).then(created => {
        console.log(created)
     }
   }
}

Is there any way to do this? How? If not, how should I design this task?

+4
source share
1 answer

One approach may be to pass (enable, reject) the parameters along with the action and force the saga to call them succcess / failure. Seems good.

https://github.com/yelouafi/redux-saga/issues/161

+2

Source: https://habr.com/ru/post/1650563/


All Articles