forked from rstudio/shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a user-extensible registry of custom Shiny Input handlers.
Brought in the existing handlers for date, matrix, and numeric. Allow users to add/remove handlers via the new addInputHandler and removeInputHandler functions. The addInputHandler function accepts a callback which wil be called with the input value, shinysession object, and element name.
- Loading branch information
1 parent
05a9204
commit a84c45f
Showing
4 changed files
with
159 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
\name{addInputHandler} | ||
\alias{addInputHandler} | ||
\title{Register an Input Handler} | ||
\usage{ | ||
addInputHandler(type, fun, force = FALSE) | ||
} | ||
\arguments{ | ||
\item{type}{The type for which the handler should be | ||
added} | ||
|
||
\item{fun}{The handler function. This is the function | ||
that 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.} \item{The \code{shinysession} in which the | ||
input exists.} \item{The name of the input.} }} | ||
|
||
\item{force}{If \code{TRUE}, will overwrite any existing | ||
handler without warning.} | ||
} | ||
\description{ | ||
Adds an input handler for data of this type. When called, | ||
Shiny will use the function provided to refine the data | ||
passed back from the client (after being deserialized by | ||
RJSONIO) before making it available in the \code{input} | ||
variable of the \code{server.R} file. | ||
} | ||
\details{ | ||
This function will register the handler for the duration | ||
of the R process (unless Shiny is explicitly reloaded). | ||
For that reason, the \code{type} used should be very | ||
specific to this package to minimize the risk of | ||
colliding with another Shiny package which might use this | ||
data type name. | ||
|
||
The \code{type} of a custom Shiny Input widget will be | ||
deduced using the \code{getType()} JavaScript function on | ||
the registered Shiny inputBinding. | ||
} | ||
\seealso{ | ||
\code{\link{removeInputHandler}} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
\name{removeInputHandler} | ||
\alias{removeInputHandler} | ||
\title{Deregister an Input Handler} | ||
\usage{ | ||
removeInputHandler(type) | ||
} | ||
\arguments{ | ||
\item{type}{The type for which handlers should be | ||
removed.} | ||
} | ||
\value{ | ||
The handler previously associated with this \code{type}, | ||
if one existed. Otherwise, \code{NULL}. | ||
} | ||
\description{ | ||
Removes an Input Handler. Rather than using the | ||
previously specified handler for data of this type, the | ||
default RJSONIO serialization will be used. | ||
} | ||
\seealso{ | ||
\code{\link{addInputHandler}} | ||
} | ||
|