Package 'react'

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-06-08 04:44:45 UTC
Source: https://github.com/tadascience/react

Help Index


Reactivity helper

Description

The react object gives alternative syntax to call shiny reactive expressions.

Usage

react(x)

Arguments

x

the reactive call

Details

The benefit is that it makes them easier to spot in your code.

Examples

# 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)