Closed nx10 closed 2 years ago
I just added this feature.
Example:
# my_code.R
plot(rnorm(100), col = "red")
# Interactive:
hgd_watch(
watch="my_code.R", # When my_code.R changes...
on_change = function(...) {
source("my_code.R") # ...call updated plot function.
}
)
Let me know if you have any feedback.
Is your proposal related to a problem?
When creating plots in R I find it cumbersome to fine-tune parameters (colors, label texts, etc.) In web and UI development in other languages this is mitigated with watch / 'hot reload' functionality that re-runs part of the code after a file is edited (and saved) and updates the UI automatically.
Describe the solution you'd like
A possible API could look something like this:
where
watch
is a vector of files to watch for updates, andrun
is a function that will generate the updated plots.httpgd
should clear and reset itself beforerun
is called.Describe alternatives you've considered
I do not know of any available alternatives.
Edit: There are some packages who offer similar functionality for other use cases:
Additional context
Depends on https://github.com/nx10/httpgd/issues/15 to be reliable.
This is meant as a discussion. Let me know if you can think of any additional suggestions, concerns or changes.