我想解析一张Excel工作表,并且在解析之前,我希望后端有一些数据来映射它。
因此,单击“提交”按钮后,我想一个接一个地触发三个操作,并将响应存储在存储区中。我为此使用redux-saga。 在执行三个操作(api调用)之后,我将调用解析函数并使用将从存储中获取的响应进行解析和映射。
我尝试过一次分派这三个动作。但是,一旦到达网络客户端(即axios实例以调用api),它就会变为异步状态,并执行下一行。
onSubmit = () => {
/* I will set the loader on submit button till the api is called and all parsing of excel sheet is done. */
this.setState({
showLoader: true,},() => {
this.props.getData1(); //Will be saving it in store as data1
this.props.getData2(); //Will be saving it in store as data2
this.props.getData3(); //Will be saving it in store as data3
/* After this I want to call the parsing function to parse the excel sheet data and map accordingly */
parseExcelData(sheetData); //sheet data is the excel data
}
所以我希望当我调用'parseExcelData'函数时,来自存储的数据,即data1,data2和data3将在该函数中可用。 但是所有的api调用都发生在工作表被解析之后。 我已经使用saga生成器函数完成了它,并且工作正常。但是我想知道如何使用redux处理这种情况。