kinto-b / makepipe

Tools for constructing simple make-like pipelines in R.
https://kinto-b.github.io/makepipe/
GNU General Public License v3.0
30 stars 0 forks source link

Implement `make_return()` #15

Closed kinto-b closed 3 years ago

kinto-b commented 3 years ago

As per #2, we want a formal way to specify return values that unifies make_*() variants.

Something like this should work:

make_return <- function(x) {
    signalCondition(rlang::cnd("makepipe_return_cnd", res = x))
    invisible(x)
}

make_with_source <- function(...) {
  ...
  out <- tryCatch(
    source(...),
    makepipe_return_cnd = function(x) {
        x$res
    }
  )
 ... 

  out
}