Files
shiny/reference/markRenderFunction.html
2025-12-03 21:27:07 +00:00

165 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Mark a function as a render function — markRenderFunction • shiny</title><!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous"><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"><script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"><script src="../pkgdown.js"></script><meta property="og:title" content="Mark a function as a render function — markRenderFunction"><meta property="og:description" content=" Please use createRenderFunction() to
support async execution. (Shiny 1.1.0)"><meta property="og:image" content="/logo.png"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><body data-spy="scroll" data-target="#toc">
<div class="container template-reference-topic">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">shiny</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">1.12.0.9000</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"><li>
<a href="../reference/index.html">Reference</a>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul><ul class="nav navbar-nav navbar-right"><li>
<a href="https://github.com/rstudio/shiny/" class="external-link">
<span class="fab fa-github fa-lg"></span>
</a>
</li>
</ul></div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Mark a function as a render function</h1>
<small class="dont-index">Source: <a href="https://github.com/rstudio/shiny/blob/rc-v1.12.1/R/shinywrappers.R" class="external-link"><code>R/shinywrappers.R</code></a></small>
<div class="hidden name"><code>markRenderFunction.Rd</code></div>
</div>
<div class="ref-description">
<p><a href="https://lifecycle.r-lib.org/articles/stages.html#superseded" class="external-link"><img src="figures/lifecycle-superseded.svg" alt="[Superseded]"></a> Please use <code><a href="createRenderFunction.html">createRenderFunction()</a></code> to
support async execution. (Shiny 1.1.0)</p>
</div>
<div id="ref-usage">
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">markRenderFunction</span><span class="op">(</span></span>
<span> <span class="va">uiFunc</span>,</span>
<span> <span class="va">renderFunc</span>,</span>
<span> outputArgs <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span><span class="op">)</span>,</span>
<span> cacheHint <span class="op">=</span> <span class="st">"auto"</span>,</span>
<span> cacheWriteHook <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> cacheReadHook <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span></code></pre></div>
</div>
<div id="arguments">
<h2>Arguments</h2>
<dl><dt id="arg-uifunc">uiFunc<a class="anchor" aria-label="anchor" href="#arg-uifunc"></a></dt>
<dd><p>A function that renders Shiny UI. Must take a single argument:
an output ID.</p></dd>
<dt id="arg-renderfunc">renderFunc<a class="anchor" aria-label="anchor" href="#arg-renderfunc"></a></dt>
<dd><p>A function that is suitable for assigning to a Shiny output
slot.</p></dd>
<dt id="arg-outputargs">outputArgs<a class="anchor" aria-label="anchor" href="#arg-outputargs"></a></dt>
<dd><p>A list of arguments to pass to the <code>uiFunc</code>. Render
functions should include <code>outputArgs = list()</code> in their own parameter list,
and pass through the value to <code>markRenderFunction</code>, to allow app authors to
customize outputs. (Currently, this is only supported for dynamically
generated UIs, such as those created by Shiny code snippets embedded in R
Markdown documents).</p></dd>
<dt id="arg-cachehint">cacheHint<a class="anchor" aria-label="anchor" href="#arg-cachehint"></a></dt>
<dd><p>One of <code>"auto"</code>, <code>FALSE</code>, or some other information to
identify this instance for caching using <code><a href="bindCache.html">bindCache()</a></code>. If <code>"auto"</code>, it
will try to automatically infer caching information. If <code>FALSE</code>, do not
allow caching for the object. Some render functions (such as <a href="renderPlot.html">renderPlot</a>)
contain internal state that makes them unsuitable for caching.</p></dd>
<dt id="arg-cachewritehook">cacheWriteHook<a class="anchor" aria-label="anchor" href="#arg-cachewritehook"></a></dt>
<dd><p>Used if the render function is passed to <code><a href="bindCache.html">bindCache()</a></code>.
This is an optional callback function to invoke before saving the value
from the render function to the cache. This function must accept one
argument, the value returned from <code>renderFunc</code>, and should return the value
to store in the cache.</p></dd>
<dt id="arg-cachereadhook">cacheReadHook<a class="anchor" aria-label="anchor" href="#arg-cachereadhook"></a></dt>
<dd><p>Used if the render function is passed to <code><a href="bindCache.html">bindCache()</a></code>.
This is an optional callback function to invoke after reading a value from
the cache (if there is a cache hit). The function will be passed one
argument, the value retrieved from the cache. This can be useful when some
side effect needs to occur for a render function to behave correctly. For
example, some render functions call <code><a href="createWebDependency.html">createWebDependency()</a></code> so that Shiny
is able to serve JS and CSS resources.</p></dd>
</dl></div>
<div id="value">
<h2>Value</h2>
<p>The <code>renderFunc</code> function, with annotations.</p>
</div>
<div id="details">
<h2>Details</h2>
<p>Should be called by implementers of <code>renderXXX</code> functions in order to mark
their return values as Shiny render functions, and to provide a hint to Shiny
regarding what UI function is most commonly used with this type of render
function. This can be used in R Markdown documents to create complete output
widgets out of just the render function.</p>
<p>Note that it is generally preferable to use <code><a href="createRenderFunction.html">createRenderFunction()</a></code> instead
of <code>markRenderFunction()</code>. It essentially wraps up the user-provided
expression in the <code>transform</code> function passed to it, then passes the resulting
function to <code>markRenderFunction()</code>. It also provides a simpler calling
interface. There may be cases where <code>markRenderFunction()</code> must be used instead of
<code><a href="createRenderFunction.html">createRenderFunction()</a></code> for example, when the <code>transform</code> parameter of
<code><a href="createRenderFunction.html">createRenderFunction()</a></code> is not flexible enough for your needs.</p>
</div>
<div id="see-also">
<h2>See also</h2>
<div class="dont-index"><p><code><a href="createRenderFunction.html">createRenderFunction()</a></code></p></div>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
</nav></div>
</div>
<footer><div class="copyright">
<p></p><p>Developed by Winston Chang, Joe Cheng, JJ Allaire, Carson Sievert, Barret Schloerke, Garrick Aden-Buie, Yihui Xie, Jeff Allen, Jonathan McPherson, Alan Dipert, Barbara Borges, Posit Software, PBC.</p>
</div>
<div class="pkgdown">
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.2.0.</p>
</div>
</footer></div>
</body></html>