Closed gordonwoodhull closed 6 years ago
I think this is the only major obstacle to contributing our changes back to Shiny. It's also something people want in itself, for example "I'm trying to use session$onSessionEnded
to push final updates to a DB".
FWIW this SO answer provides a test
users_data <- data.frame(START = Sys.time())
session$onSessionEnded(function() {
users_data$END <- Sys.time()
# Write a file in your working directory
write.table(x = users_data, file = file.path("/tmp/users_data.txt"),
append = TRUE, row.names = FALSE, col.names = FALSE, sep = "\t")
})
Only difference is using getwd()
for the path didn't work for me, since the temporary directory gets deleted when the session closes. This tripped me up for a minute or two.
Implemented in #31
Currently we've disabled all shutdown code in our override of
shiny:::runApp
, because we need the function to return control, not block until done.Can we put all of the
on.exit()
functionality that's currently commented out into a separateshutdownApp
function, that we call explicitly when the page is closed?