Delay Rendering for an Expression

Share:

Description

In a Shiny document, evaluate the given expression after the document has finished rendering, instead of during render.

Usage

1
render_delayed(expr)

Arguments

expr

The expression to evaluate.

Details

This function is useful inside Shiny documents. It delays the evaluation of its argument until the document has finished its initial render, so that the document can be viewed before the calculation is finished.

Any expression that returns HTML can be wrapped in render_delayed.

Value

An object representing the expression.

Note

expr is evaluated in a copy of the environment in which the render_delayed call appears. Consequently, no side effects created by expr are visible in succeeding expressions, nor are changes to the environment after the call to render_delayed visible to expr.

expr must be an expression that produces HTML.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 

# Add the following code to an R Markdown document

div(Sys.time())

render_delayed({
 Sys.sleep(3)      # simulate an expensive computation
 div(Sys.time())
})

div(Sys.time())

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.