| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/reactive-domains.R |
| 3 |
\name{domains} |
| 4 |
\alias{domains} |
| 5 |
\alias{getDefaultReactiveDomain} |
| 6 |
\alias{withReactiveDomain} |
| 7 |
\alias{onReactiveDomainEnded} |
| 8 |
\title{Reactive domains} |
| 9 |
\usage{ |
| 10 |
getDefaultReactiveDomain() |
| 11 |
|
| 12 |
withReactiveDomain(domain, expr) |
| 13 |
|
| 14 |
onReactiveDomainEnded(domain, callback, failIfNull = FALSE) |
| 15 |
} |
| 16 |
\arguments{ |
| 17 |
\item{domain}{A valid domain object (for example, a Shiny session), or |
| 18 |
\code{NULL}} |
| 19 |
|
| 20 |
\item{expr}{An expression to evaluate under \code{domain}} |
| 21 |
|
| 22 |
\item{callback}{A callback function to be invoked} |
| 23 |
|
| 24 |
\item{failIfNull}{If \code{TRUE} then an error is given if the \code{domain} |
| 25 |
is \code{NULL}} |
| 26 |
} |
| 27 |
\description{ |
| 28 |
Reactive domains are a mechanism for establishing ownership over reactive |
| 29 |
primitives (like reactive expressions and observers), even if the set of |
| 30 |
reactive primitives is dynamically created. This is useful for lifetime |
| 31 |
management (i.e. destroying observers when the Shiny session that created |
| 32 |
them ends) and error handling. |
| 33 |
} |
| 34 |
\details{ |
| 35 |
At any given time, there can be either a single "default" reactive domain |
| 36 |
object, or none (i.e. the reactive domain object is \code{NULL}). You can |
| 37 |
access the current default reactive domain by calling |
| 38 |
\code{getDefaultReactiveDomain}. |
| 39 |
|
| 40 |
Unless you specify otherwise, newly created observers and reactive |
| 41 |
expressions will be assigned to the current default domain (if any). You can |
| 42 |
override this assignment by providing an explicit \code{domain} argument to |
| 43 |
\code{\link[=reactive]{reactive()}} or \code{\link[=observe]{observe()}}. |
| 44 |
|
| 45 |
For advanced usage, it's possible to override the default domain using |
| 46 |
\code{withReactiveDomain}. The \code{domain} argument will be made the |
| 47 |
default domain while \code{expr} is evaluated. |
| 48 |
|
| 49 |
Implementers of new reactive primitives can use \code{onReactiveDomainEnded} |
| 50 |
as a convenience function for registering callbacks. If the reactive domain |
| 51 |
is \code{NULL} and \code{failIfNull} is \code{FALSE}, then the callback will |
| 52 |
never be invoked. |
| 53 |
} |