getTime <- function() as.integer(Sys.time())runApp(list( ui = fluidPage( textInput("time", "Time", getTime()), actionButton("update", "Update") ), server = function(input, output, session) { observeEvent(input$update, { updateTextInput(session, "time", value = getTime()) cat(input$time, "\n") }) }))
updateTextInput how sendInputMessage is working.
Sigbert
observeEvent(input$update, {temp <- getTime()
updateTextInput(session, "time", value = temp)
cat(temp, "\n")})
observeEvent(input$update, {
updateTextInput(session, "time", value = getTime())
updateTextInput(session, "test1", value = "test1")
updateTextInput(session, "test2", value = "test2")
helperFunction(input) })
inp <- list(a=1)
helperFunction <- function(input) { str(input) }
server <- function (session, input) {
helperFunction(input)
myUpdateTextInput(session, "time", value = 0)
myUpdateTextInput(session, "test1", value = "test1")
myUpdateTextInput(session, "test2", value = "test2")
helperFunction(input)
}
myUpdateTextInput <- function (session, inputId, label = NULL, value = NULL)
{ ##maybe another environment instead of "parent.frame()" is necessary
input <- get("input", envir = parent.frame())
input[[inputId]] <- value
assign("input", input, envir = parent.frame())
##next line commented such that the program runs without shiny library
#updateTextInput(session, inputId, label, value)
}
server(list(),inp)