Skip to contents

These functions support async request handling. You can register your own as well using register_async().

Usage

mirai_async(...)

Arguments

...

Further argument passed on to the internal async function. See Details for information on which function handles the formatting internally in each async evaluator

Value

A function taking expr and envir. The former is the expression to evaluate and the latter is an environment with additional variables that should be made available during evaluation

Provided evaluators

  • mirai_async() uses mirai::mirai(). It is registered as "mirai". Be aware that for this evaluator to be performant you should start up multiple persistent background processes. See mirai::daemons().

Examples

# Use the default mirai backend by setting `async = TRUE` with a handler

pa <- api() |>
  api_get("/hello/<name:string>", function(name) {
    list(
      msg = paste0("Hello ", name, "!")
    )
  }, async = TRUE)
#> Creating default route in request router