Skip to content

☢️ Reactivity helper for 'shiny' ✨

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

tadascience/react

Repository files navigation

react

R-CMD-check

The goal of react is to help with reactivity, instead of calling the foo reactive expression foo() you can call react$foo similar to how one calls input$bar for inputs, or alternatively react[foo] or react[foo()].

The benefit is that it makes it easier to spot calls to reactive expressions in your server code.

Installation

You can install the development version of react from GitHub with:

pak::pak("tadascience/react")

Examples

Take this from the shiny example:

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(dataInput(), theme = chartTheme("white"),
                type = "line", log.scale = input$log, TA = NULL)
  })

}

With react you can rewrite the plot output as one of these, depending on your taste.

  # react$ is similar conceptually to how input$ works
  output$plot <- renderPlot({
    chartSeries(react$dataInput, theme = chartTheme("white"),
                type = "line", log.scale = input$log, TA = NULL)
  })
  
  # react[] 
  output$plot <- renderPlot({
    chartSeries(react[dataInput], theme = chartTheme("white"),
                type = "line", log.scale = input$log, TA = NULL)
  })
  
  # react[()] so that you still have the calling a function feel
  #           and you just sourround it
  output$plot <- renderPlot({
    chartSeries(react[dataInput()], theme = chartTheme("white"),
                type = "line", log.scale = input$log, TA = NULL)
  })
  

About

☢️ Reactivity helper for 'shiny' ✨

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages