# Build a valid IPC message envelope
msg <- RDesk::rdesk_message("get_data", list(filter = "cyl == 6"))
str(msg)
#> List of 5
#> $ id : chr "msg_177463054444.706_580"
#> $ type : chr "get_data"
#> $ version : chr "1.0"
#> $ payload :List of 1
#> ..$ filter: chr "cyl == 6"
#> $ timestamp: num 1.77e+09Copy-paste recipes for the most common RDesk patterns.
app$on_message("load_file", function(payload) {
path <- app$dialog_open(
title = "Open CSV",
filters = list("CSV files" = "*.csv")
)
if (is.null(path)) return(invisible(NULL))
df <- utils::read.csv(path, stringsAsFactors = FALSE)
app$send("file_loaded", list(
rows = nrow(df),
cols = names(df),
filename = basename(path)
))
})
app$on_message("export_csv", function(payload) {
path <- app$dialog_save(
title = "Save CSV",
filters = list("CSV files" = "*.csv"),
default_name = "export.csv"
)
if (is.null(path)) return(invisible(NULL))
write.csv(mtcars, path, row.names = FALSE)
app$toast(paste("Saved to", basename(path)), type = "success")
})# In app.R, before app$run()
rdesk_auto_update(
current_version = "1.0.0",
version_url = "https://yourserver.com/latest.txt",
download_url = "https://yourserver.com/MyApp-setup.exe",
app = app
)Host a plain text file at version_url containing only
the latest version string, e.g. 1.1.0. RDesk checks it
silently on launch and installs the update if a newer version is
available.