Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Sep 29, 2020 · 4 comments
Open

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

ghost opened this issue Sep 29, 2020 · 4 comments
Milestone

Comments

@ghost
Copy link

ghost commented Sep 29, 2020


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
Copy link
Collaborator

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)

@schloerke schloerke changed the title Download the interactive reactlog reactlog_write() output can not be used after being read back Sep 29, 2020
@schloerke schloerke added this to the v1.2.0 milestone Sep 29, 2020
@ghost
Copy link
Author

ghost commented Oct 7, 2020

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
Copy link
Collaborator

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants