init {gargoyle} | R Documentation |
Initiate, triger, event
Description
Initiate, triger, event
Usage
init(..., session = getDefaultReactiveDomain())
trigger(..., session = getDefaultReactiveDomain())
watch(name, session = getDefaultReactiveDomain())
Arguments
session |
The shiny session object |
name , ... |
The name(s) of the events |
Value
The 'session' object invisibly. These functions are mainly used for side-effects.
Examples
if (interactive()){
library(shiny)
library(gargoyle)
options("gargoyle.talkative" = TRUE)
ui <- function(request){
tagList(
h4('Go'),
actionButton("y", "y"),
h4('Output of z$v'),
tableOutput("evt")
)
}
server <- function(input, output, session){
# Initiating the flags
init( "plop", "pouet", "poum")
# Creating a new env to store values, instead of
# a reactive structure
z <- new.env()
observeEvent( input$y , {
z$v <- mtcars
# Triggering the flag
trigger("airquality")
})
on("airquality", {
# Triggering the flag
z$v <- airquality
trigger("iris")
})
on("iris", {
# Triggering the flag
z$v <- iris
trigger("renderiris")
})
output$evt <- renderTable({
# This part will only render when the renderiris
# flag is triggered
watch("renderiris")
head(z$v)
})
}
shinyApp(ui, server)
}
[Package gargoyle version 0.0.1 Index]