Skip to content

Documentation: how to use r or r_bg in a package to call other package functions #147

@daattali

Description

@daattali

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions