A (quoted or unquoted) expression that represents the event; this can be a simple reactive value likeinput$click
, a call to a reactive expression likedataset()
, or even a complex expression inside curly braces
library(shiny)
ui <- fluidPage( numericInput("a", "a", 0), textInput("b", "b"))
server <- function(input, output, session) { observeEvent({ input$a input$b },{ print(sprintf( "Either 'a' or 'b' changed (a = %s; b = '%s')", input$a, input$b )) })}
shinyApp(ui, server)
library(shiny)
ui <- fluidPage( numericInput("a", "a", 0), textInput("b", "b"))
server <- function(input, output, session) { observe({ print(sprintf( "Either 'a' or 'b' changed (a = %s; b = '%s')", input$a, input$b )) })}
shinyApp(ui, server)
library(shiny)
ui <- fluidPage( numericInput("a", "a", 0), textInput("b", "b"))
server <- function(input, output, session) { observeEvent({ if ((input$a > 10) && isTruthy(input$b)) TRUE else return() },{ print(sprintf( "'a' is greater than 10 and is 'b' is truthy (a = %s; b = '%s')", input$a, input$b )) })}
shinyApp(ui, server)
library(shiny)
ui <- fluidPage( numericInput("a", "a", 0), textInput("b", "b"))
server <- function(input, output, session) { observeEvent(reactiveValuesToList(input), { if ((input$a > 10) && isTruthy(input$b)) { print(sprintf( "'a' is greater than 10 and is 'b' is truthy (a = %s; b = '%s')", input$a, input$b )) } })}
shinyApp(ui, server)
library(shiny)
ui <- fluidPage(
numericInput("a", "a", 0),
textInput("b", "b"),
actionButton("c","c")
)
server <- function(input, output, session) {
observeEvent({
input$a
input$b
input$c
},{
print(sprintf(
"Either 'a' or 'b' or 'c' changed (a = %s; b = '%s', c=%s)",
input$a, input$b, input$c
))
})
}
shinyApp(ui, server)
library(shiny)
ui <- fluidPage(fluidRow(column( 4,
numericInput("a", "a", 0),
textInput("b", "b")
, actionButton("c","c")
),
column(8, textOutput("out1"))
))
server <- function(input, output, session) {
observeEvent({
input$a
input$b
input$c
},{
print(sprintf(
"Either 'a' or 'b' or 'c' changed (a = %s; b = '%s', c=%s)",
input$a, input$b , input$c
))
}, ignoreNULL = FALSE)
}
shinyApp(ui, server)
[1] "Either 'a' or 'b' or 'c' changed (a = 0; b = '', c=0)" [1] "Either 'a' or 'b' or 'c' changed (a = 0; b = '', c=1)"
So all looks as expected. Just to summarize:
--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/vd_nB-BH8sw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/1b5ef89c-1b28-4f34-933c-14e886964ec7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[1] "Either 'a' or 'b' or 'c' changed (a = 0; b = '', c=1)"
library(shiny)ui <- fluidPage(actionButton("c","c"))
server <- function(input, output, session) {
observeEvent({ input$c },{ print(sprintf("'c' changed (c = %s)", input$c))
}, ignoreNULL = FALSE)}
shinyApp(ui, server)
library(shiny)
ui <- fluidPage(
numericInput("a", "a", 0),
textInput("b", "b"),
actionButton("c","c")
)
server <- function(input, output, session) {
observeEvent({
input$a
input$c
input$b
},{
print(sprintf(
"Either 'a' or 'b' or 'c' changed (a = %s; b = '%s', c=%s)",
input$a, input$b, input$c
))
})
}
shinyApp(ui, server)
Wow. Thanks for the insight on how this really works! - Tom
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/27d7854d-0c07-482c-9a82-5729e942fa41%40googlegroups.com.