This function prepares a structure that defines all aspects of an input type: UI creation, UI updating, observer function and string representation of the input value.

inputHandler(
  create.ui = function(x, ns = identity, value = NULL) {     tags$div(id =
    session$ns(x$id)) },
  default.value = "",
  params.list = list(),
  update.ui = function(x, session) { },
  get.input = function(x, session) {     return(list(session$input[[x$id]])) },
  set.input = function(x, session, value) {     update.ui(x, session, value) },
  as.value = function(x, session = NULL, value = NULL) {     if (is.null(value))       
      value <- getHandler(x)$get.input(x, session)[[1]]     value <- as.character(value) 
       if (length(value) > 1)          stop("input must have length 1.")    
    return(value) },
  as.string = function(x, session, value = NULL) {     getHandler(x)$as.value(x,
    session, value) %>% toString },
  as.source = function(x, session = NULL, value = NULL) {     getHandler(x)$as.value(x,
    session, value) %>% as.character },
  observer = function(x, session) { }
)

Arguments

create.ui

function used to create the input UI.

default.value

default value of this input type

params.list

list of parameters used by the input type. Each element of the list describes a parameter and has the following members: name (pretty name of the parameter), type (one of character, numeric, logical, choices), choices (when type is choices, the vector of allowed values), default (default value).

update.ui

function used to update the input UI.

get.input

function that returns the raw input(s) from the session$input object as a list.

as.value

function that transforms the value from get.input() to the appropriate format for the input type. If value is provided, then the function tries to coerce this value to the appropriate type.

as.source

function that transforms the value from as.value() to source code.

observer

actions to be taken as an observer of any reactive expression(s).

Value

the list of functions to handle the the input type.

Details

The default functions assume a single input and return the value without transformations get.input() returns a list of one element, as.value unlists this element, and as.source() returns that value as a character value.