rdesk_watch enables live monitoring of R source files and UI asset files (HTML, CSS, JS).
When a UI file changes, the application automatically reloads the page. When an R script changes,
the framework sources the modified module and automatically re-binds application event handlers.
Details
RDesk hot reload works by polling file modification times once per event loop iteration (roughly every 10 ms). When a change is detected:
- R files
The modified file is
source()d in the global environment. If a function namedinit_handlersexists in the global environment, it is called with the App instance so that message handlers are re-registered.- HTML/CSS/JS files
A
__reload_ui__message is sent to the frontend, triggering a full page reload in the WebView.
Hot reloading is designed for development only. It should not be enabled in bundled production builds.
Examples
if (interactive()) {
app <- App$new(title = "My App")
rdesk_watch(app) # or equivalently: app$watch(TRUE)
app$run()
}
