coro
coro copied to clipboard
programmatic async function creation
It would be nice to programmatically create an async function, such as when you want to convert an expression into an anonymous function.
An example interface could be:
as_async_function(
{ await(foo) }
)
At the moment we can only pass anonymous functions to coro::async
because of the substitute call in coro::: assert_lambda
. Technically I could use coro:::generator0(fn, type = "async")
, but it seems it's not exported for a reason.
You can get half of the way with rlang::inject
, but it's a bit hacky and you can't use it to set the formals of the anonymous function.