如何在React Redux-Saga中为yield调用设置超时

时间:2019-03-08 10:26:27

标签: reactjs react-redux redux-saga

在我的其余API后端中,我会进行大量处理,通常需要1.5分钟才能产生结果,那时候我在前端react应用程序中遇到了此错误。

Error: timeout of 60000ms exceeded

因此,对等连接丢失。

如何在redux-saga中设置请求超时

3 个答案:

答案 0 :(得分:0)

import { eventChannel, END } from 'redux-saga'

function countdown(secs) {
  return eventChannel(emitter => {
      const iv = setInterval(() => {
        secs -= 1
        if (secs > 0) {
          emitter(secs)
        } else {
          // this causes the channel to close
          emitter(END)
        }
      }, 1000);
      // The subscriber must return an unsubscribe function
      return () => {
        clearInterval(iv)
      }
    }
  )
}

希望这会有所帮助。

答案 1 :(得分:0)

"<" + thatChar + ">"

答案 2 :(得分:0)

我曾经race被用于此类事情。可能对您有用。

=query({C4:E11, transpose(query(transpose(F4:S11),,9^99))}, "Select AVG(Col1) where Col3='"&L1&"' and Col4 contains 'Frankrijk vakantie' and Col4 contains 'Europa vakantie' label AVG(Col1)''", 0)