Explicit cache of a function.

make_flow_fn(fn, fn_id = NULL, flow_options = get_flow_options())

Arguments

fn

Function to be cached, ideally a pure function.

fn_id

Optional id to uniquely identify the function. By default, rflow functions reuse the cache if the same function is given. The id allows the user to suppress console messages and to explicitly indicate whether to reuse the old cache or create a new one.

flow_options

List of options created using get_flow_options.

Value

The cached version of the function.

Details

In order to use the functionality of an R6Flow object, the output of make_flow_fn has to be collected first.

Examples

fn <- function(x, y) { x + y + 1 } make_flow_function <- make_flow_fn(fn)
#> New cache: fn=fn / fn_id=1 / fn_key=6d804461dfeebfa4
rflow_function <- make_flow_function(2, 3) flow_result <- rflow_function %>% collect() # usage with rflow pipes fn2 <- function(x, y) { x * y } make_flow_function2 <- make_flow_fn(fn2)
#> Reusing cache: fn=fn2 / fn_id=1 / fn_key=744dc98f5cf70f9b
collected_pipe_flow <- make_flow_function(1, 2) %>% make_flow_function2(2) %>% collect()