rstudio / reactlog

Shiny Reactivity Visualizer
http://rstudio.github.io/reactlog
Other
121 stars 9 forks source link

`reactlog_write()` output can not be used after being read back #71

Open ghost opened 3 years ago

ghost commented 3 years ago

How to download the intreactive Reactlog

I want to download or store the html file produced by reactlog so that i can see it later even if the program is closed or the reactlog is reset. There is a reactlog_write() function that puts it into a json file but how to use that json file again to create or generate the reactlog.

library(shiny)
library(reactlog)
# tell shiny to log all reactivity

reactlog_enable()
reactlogReset()

# run a shiny app
app <- system.file("examples/01_hello", package = "shiny")
runApp(app)

# once app has closed, display reactlog from shiny
shiny::reactlogShow()
reactlog_write(reactlog(),file = "test1.json")

image


How to use this file test1.json to produce the interative reactlog again ?

schloerke commented 3 years ago

Dang. Attributes are lost when saving to regular json. 😞

For now...

### add elements to reactlog
library(shiny)
library(reactlog)
# tell shiny to log all reactivity

reactlog_enable()
reactlogReset()

# run a shiny app
app <- system.file("examples/01_hello", package = "shiny")
runApp(app)
###

# save to disk
writeLines(jsonlite::serializeJSON(shiny::reactlog()), file = "test2.json")

# ---------

# restore reactlog to an object
my_reactlog <- jsonlite::unserializeJSON(readLines("test2.json")[1])

# view reactlog object
reactlog::reactlog_show(my_reactlog)
ghost commented 3 years ago

Can we save the html directly without storing to the json ? I can see in the Readme, that one of the reactlog html has been shown. I also want to store the html for later use how to do that ?

schloerke commented 3 years ago

Your browser can store the webpage as a "web archive". The html is not a standalone file. For the readme, I have to copy over the assets to make the images / css / js work.

(For context, I am aware that it would be very nice if it was an htmlwidget to be able to easily include it in other locations.)

royfrancis commented 2 months ago

Any updates here? Would it be possible to include a reactlog output in a quarto document?