Javascript 如何为两个redux操作创建异步/等待结构?

Javascript 如何为两个redux操作创建异步/等待结构?,javascript,reactjs,redux,async-await,react-redux,Javascript,Reactjs,Redux,Async Await,React Redux,我有两个按钮改变功能,这是相互依赖的行动。我想做的是,我想把这两个函数放在异步/等待结构中,以便在update\u other\u filter操作结束后,我能够运行getTotalData操作。按照下面的结构运行它实际上并不能以正确的方式更新状态。我正在getTotaldata中发送以前的状态(在更新\u其他\u筛选器之前) 你们可能会说,当问题解决时,我必须在update\u other\u filter操作中发送getTotalData。但在我的项目的这种状态下,我似乎无法改变任何事情。我

我有两个按钮改变功能,这是相互依赖的行动。我想做的是,我想把这两个函数放在异步/等待结构中,以便在update\u other\u filter操作结束后,我能够运行getTotalData操作。按照下面的结构运行它实际上并不能以正确的方式更新状态。我正在getTotaldata中发送以前的状态(在更新\u其他\u筛选器之前)

你们可能会说,当问题解决时,我必须在update\u other\u filter操作中发送getTotalData。但在我的项目的这种状态下,我似乎无法改变任何事情。我不太擅长使用async/await和Promissions概念,因此,我只想在react组件中创建async/await函数,而不是在onChange函数中调用它。有办法吗

onChange = {(event) => {
      this.props.setSpinner()
      //this update filter function updates filter which will be sent to server in getTotalData action
      this.props.update_other_filter(true,"website",!event.target.checked)
      //this action should wait for update_other_filter to end than it has correct parameters to send to server
      this.props.getTotalData(this.props.totalFilters, apiUrl)
      }

Hocamçok teşekkürlerHocamçok teşekkürlerThis实际上不起作用。onChange是输入html字段的函数。我可以使onChange或onClick函数异步。这实际上不起作用。onChange是输入html字段的函数。我可以使onChange或onClick函数异步吗。
async onChange = {(event) => {
   this.props.setSpinner()
   await this.props.update_other_filter(true,"website",!event.target.checked)
   this.props.getTotalData(this.props.totalFilters, apiUrl)
}
// I will make function wait that needs for dependent function and also add some error handling.

async onChange = {(event) => {
   this.props.setSpinner()
   try
   {
   await this.props.update_other_filter(true,"website",!event.target.checked)
   this.props.getTotalData(this.props.totalFilters, apiUrl)
   }
   catch(e)
   {
     thorw e;
    }
}