coro icon indicating copy to clipboard operation
coro copied to clipboard

programmatic async function creation

Open ElianHugh opened this issue 5 months ago • 3 comments

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.

ElianHugh avatar Jan 18 '24 05:01 ElianHugh