https://github.com/colearendt/shiny-reactive-global
An example Shiny app with a "global reactive" that runs on a timer
https://github.com/colearendt/shiny-reactive-global
experiment reactive shiny
Last synced: 2 months ago
JSON representation
An example Shiny app with a "global reactive" that runs on a timer
- Host: GitHub
- URL: https://github.com/colearendt/shiny-reactive-global
- Owner: colearendt
- Created: 2020-05-03T09:21:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-03T09:44:28.000Z (about 5 years ago)
- Last Synced: 2025-02-14T13:16:12.717Z (4 months ago)
- Topics: experiment, reactive, shiny
- Language: R
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Shiny Reactive (Global)
Unfortunately, `reactivePoll` and other such things do not work as expected
outside of Shiny's reactive context. This is particularly apparent when wanting
to run a "global" (i.e. in the main R process) process every X seconds.Enter the solution:
```
observe(invalidateLater(x))
```This has some funky consequences in a development context that could probably be
remedied with some creative programming... but I just restart my R session.**NOTE:** It may be tempting to feel like this pattern could work in any generic
R process. Alas, it is not so - `shiny` does specific checking of the
`invalidateLater()` tree and such that we take advantage of here. You can
probably accomplish this in generic R with `future` or `promises` or some such.