Block the current runtime until the expression returns TRUE.

wait_until(
  expr,
  envir = parent.frame(),
  timeout = Inf,
  interval = 0.1,
  later_run_now = TRUE
)

Arguments

expr

an expression to check, supports quasiquotation.

envir

the environment in which the expression is to be evaluated.

timeout

raise an error if this amount of time in second has passed.

interval

delay between retries.

later_run_now

execute later::run_now() periodically later is loaded?

Examples


s <- Sys.time()
system.time(wait_until(Sys.time() - s > 1))
#>    user  system elapsed 
#>   0.005   0.001   1.041 

z <- 0
later::later(function() z <<- 1, 1)
wait_until(z == 1)
z == 1
#> [1] TRUE