Title: | An Event-Based Mechanism for 'Shiny' |
---|---|
Description: | An event-Based framework for building 'Shiny' apps. Instead of relying on standard 'Shiny' reactive objects, this package allow to relying on a lighter set of triggers, so that reactive contexts can be invalidated with more control. |
Authors: | Colin Fay [aut, cre] |
Maintainer: | Colin Fay <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1 |
Built: | 2024-11-14 04:44:21 UTC |
Source: | https://github.com/colinfay/gargoyle |
Get / Clear the logs of all the time the 'trigger()' functions are launched.
get_gargoyle_logs() clear_gargoyle_logs()
get_gargoyle_logs() clear_gargoyle_logs()
A data.frame of the logs.
if (interactive()){ get_gargoyle_logs() clear_gargoyle_logs() }
if (interactive()){ get_gargoyle_logs() clear_gargoyle_logs() }
Initiate, trigger, event
init(..., session = getDefaultReactiveDomain()) trigger(..., session = getDefaultReactiveDomain()) watch(name, session = getDefaultReactiveDomain())
init(..., session = getDefaultReactiveDomain()) trigger(..., session = getDefaultReactiveDomain()) watch(name, session = getDefaultReactiveDomain())
session |
The shiny session object |
name , ...
|
The name(s) of the events |
The 'session' object invisibly. These functions are mainly used for side-effects.
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("airquality", "iris", "renderiris") # 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) }
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("airquality", "iris", "renderiris") # 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) }
React on an event
on(name, expr, session = getDefaultReactiveDomain())
on(name, expr, session = getDefaultReactiveDomain())
name |
the name of the event to react to |
expr |
the expression to run when the event is triggered. |
session |
The shiny session object |
An observeEvent object. This object will rarely be used, 'on' is mainly called for side-effects.