This function is a wrapper for markRenderFunction()
which provides support
for async computation via promises.
createRenderFunction( func, transform = function(value, session, name, ...) value, outputFunc = NULL, outputArgs = NULL, cacheHint = "auto", cacheWriteHook = NULL, cacheReadHook = NULL )
func | A function without parameters, that returns user data. If the returned value is a promise, then the render function will proceed in async mode. |
---|---|
transform | A function that takes four arguments: |
outputFunc | The UI function that is used (or most commonly used) with this render function. This can be used in R Markdown documents to create complete output widgets out of just the render function. |
outputArgs | A list of arguments to pass to the |
cacheHint | One of |
cacheWriteHook | Used if the render function is passed to |
cacheReadHook | Used if the render function is passed to |
An annotated render function, ready to be assigned to an
output
slot.
# A very simple render function renderTriple <- function(x) { x <- substitute(x) if (!rlang::is_quosure(x)) { x <- rlang::new_quosure(x, env = parent.frame()) } func <- quoToFunction(x, "renderTriple") createRenderFunction( func, transform = function(value, session, name, ...) { paste(rep(value, 3), collapse=", ") }, outputFunc = textOutput ) } # Test render function from the console a <- 1 r <- renderTriple({ a + 1 }) a <- 2 r()#> [1] "3, 3, 3"