Title: | Reactivity Helper for 'shiny' |
---|---|
Description: | Tools to help with 'shiny' reactivity. The 'react' function offers alternative ways to call reactive expressions to better identify them in the server code. |
Authors: | Romain François [aut, cre] |
Maintainer: | Romain François <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2024.1.0.9000 |
Built: | 2024-11-05 04:11:33 UTC |
Source: | https://github.com/tadascience/react |
The react
object gives alternative syntax to call
shiny reactive expressions.
react(x)
react(x)
x |
the reactive call |
The benefit is that it makes them easier to spot in your code.
# This works by invoking the function from the parent environment # with no arguments ... foo <- function() { 42 } react$foo react[foo] react[foo()] # You can also use `react()` as a function to wrap the # reactive call react(foo()) # The benefit is that `react()` can also wrap `input$` calls # so that you easily recognize reactivity ## Not run: # ... but it only becomes relevant when used in shiny # server code, e.g. this app from the shiny page # with react$dataInput instead of dataInput() server <- function(input, output) { dataInput <- reactive({ getSymbols(input$symb, src = "yahoo", from = input$dates[1], to = input$dates[2], auto.assign = FALSE) }) output$plot <- renderPlot({ chartSeries(react$dataInput, theme = chartTheme("white"), type = "line", log.scale = input$log, TA = NULL) }) } ## End(Not run)
# This works by invoking the function from the parent environment # with no arguments ... foo <- function() { 42 } react$foo react[foo] react[foo()] # You can also use `react()` as a function to wrap the # reactive call react(foo()) # The benefit is that `react()` can also wrap `input$` calls # so that you easily recognize reactivity ## Not run: # ... but it only becomes relevant when used in shiny # server code, e.g. this app from the shiny page # with react$dataInput instead of dataInput() server <- function(input, output) { dataInput <- reactive({ getSymbols(input$symb, src = "yahoo", from = input$dates[1], to = input$dates[2], auto.assign = FALSE) }) output$plot <- renderPlot({ chartSeries(react$dataInput, theme = chartTheme("white"), type = "line", log.scale = input$log, TA = NULL) }) } ## End(Not run)