context.waitFor(condition[, options])


  • condition <Function> | <AsyncFunction> 一个断言函数,会定期调用直到成功完成或者定义的轮询超时结束。成功完成的定义是不抛出异常或拒绝。此函数不接受任何参数,并且允许返回任何值。
  • options <Object> 轮询操作的可选配置对象。支持以下属性:
    • interval <number>condition 调用失败后等待再次尝试之前的毫秒数。默认值: 50
    • timeout <number> 投票超时时间,单位为毫秒。如果在此时间结束前 condition 尚未成功,将会发生错误。默认值: 1000
  • 返回:<Promise>,其值为 condition 返回的值。

该方法会轮询 condition 函数,直到该函数成功返回或操作超时。

【This method polls a condition function until that function either returns successfully or the operation times out.】