Files
shiny/man/parseShinyInput.Rd
trestletech f4ada70e56 Customize dispatch for NULL objects.
Don't provide class for input objects based on `type` field. Provide real NULLs to dispatched functions rather than empty lists.
2013-10-18 17:27:28 -05:00

39 lines
1.4 KiB
R

\name{parseShinyInput}
\alias{parseShinyInput}
\title{Provide the new generic for parsing Shiny Input}
\usage{
parseShinyInput(x, ...)
}
\description{
Provides an S3 generic to parse incoming Shiny JSON data.
When defined on a particular class, Shiny will use S3
dispatch to refine the data passed back from the client
before making it available in the \code{input} variable
of the \code{server.R} file.
}
\details{
The \code{type} of a custom Shiny Input widget will be
deduced using the \code{getType()} JavaScript function on
the registered Shiny inputBinding.
The provided function will be used to parse the data
delivered from the client before it is available in the
\code{input} variable. The function will be called with
the following three parameters: \enumerate{ \item{The
value of this input as provided by the client,
deserialized using RJSONIO, then passed through a call to
\code{\link{structure}} to set the class of the object.
Note that the call to \code{structure} does convert
\code{NULL} values to an empty \code{\link{list}}.}
\item{The \code{shinysession} in which the input exists.}
\item{The name of the input.} }
}
\examples{
parseShinyInput.myNonNullClass <- function(x, ...){
# Check for an empty list (the NULL equivalent after setting a class using
# `structure`).
ifelse((is.list(val) && length(val) == 0), NA, val)
}
}