-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
83 lines (62 loc) · 2.22 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# react <a href="https://react.tada.science"><img src="man/figures/logo.png" align="right" height="138" /></a>
<!-- badges: start -->
[![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)
<!-- badges: end -->
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)
})
```