Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tadascience/react
☢️ Reactivity helper for 'shiny' ✨
https://github.com/tadascience/react
r shiny shiny-r
Last synced: 8 days ago
JSON representation
☢️ Reactivity helper for 'shiny' ✨
- Host: GitHub
- URL: https://github.com/tadascience/react
- Owner: tadascience
- License: other
- Created: 2024-01-26T18:27:14.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-09T16:33:16.000Z (10 months ago)
- Last Synced: 2024-10-13T02:08:04.905Z (2 months ago)
- Topics: r, shiny, shiny-r
- Language: R
- Homepage: https://react.tada.science/
- Size: 4.68 MB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - tadascience/react - ☢️ Reactivity helper for 'shiny' ✨ (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[![R-CMD-check](https://github.com/tadascience/react/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tadascience/react/actions/workflows/R-CMD-check.yaml)
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](https://github.com/) with:
``` r
pak::pak("tadascience/react")
```## Examples
Take this from the shiny example:
```r
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.```r
# 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)
})
```