Suppose I'm developing a package mypkg that has a function myfxn() that makes a call to another internal (ie not exported) function:
#' @export
myfxn <- function() {
some_slow_fxn()
}
Because this is slow, I want to run it in a background process asynchly. So I naively tried
#' @export
myfxn <- function() {
callr::r_bg(function() some_slow_fxn())
}
But this doesn't work because could not find function "some_slow_fxn"
I could use myfxn:::some_slow_fxn instead, but then CRAN would cry, and so would I.
I could probably pass in the function itself as an argument, but that seems terrible. There must be a proper solution that I'm somehow overlooking, but I couldn't find any info in the documentation about how to use in a package.