async (version 0.0.0.9004)

async: Create an async function

Description

Create an async function, that returns a deferred value, from a regular function. If fun is already an async function, then it does nothing, just returns it.

Usage

async(fun)

Arguments

fun

Original function.

Value

Async version of the original function.

Details

The result function will have the same arguments, with the same default values, and the same environment as the original input function.

Examples

Run this code
# NOT RUN {
f <- function(x) 42
af <- async(f)
is_async(f)
is_async(af)
f()
synchronise(dx <- af())
dx
# }

Run the code above in your browser using DataLab