context.waitFor(condition[, options])


  • condition <Function> | <AsyncFunction> 定期调用断言函数,直到成功完成或定义的轮询超时过去。成功完成定义为不抛出或拒绝。此函数不接受任何参数,并允许返回任何值。

    ¥condition <Function> | <AsyncFunction> An assertion function that is invoked periodically until it completes successfully or the defined polling timeout elapses. Successful completion is defined as not throwing or rejecting. This function does not accept any arguments, and is allowed to return any value.

  • options <Object> 轮询操作的可选配置对象。支持以下属性:

    ¥options <Object> An optional configuration object for the polling operation. The following properties are supported:

    • interval <number>condition 调用失败后再次尝试之前等待的毫秒数。默认值:50

      ¥interval <number> The number of milliseconds to wait after an unsuccessful invocation of condition before trying again. Default: 50.

    • timeout <number> 轮询超时(以毫秒为单位)。如果 condition 在此期间尚未成功,则会发生错误。默认值:1000

      ¥timeout <number> The poll timeout in milliseconds. If condition has not succeeded by the time this elapses, an error occurs. Default: 1000.

  • 返回:<Promise>condition 返回的值完成。

    ¥Returns: <Promise> Fulfilled with the value returned by condition.

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

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