Skip to contents

Called from download handler and used to write a saved state value if that is null

Usage

ASM_load_state(state, session, file_path)

Arguments

state

ASM state from ASM_fetch_state()

session

Shiny session variable

file_path

Zip file with the saved sate

Value

This function only writes the state and returns a list with the following elements:

  • isgood: Boolean indicating the exit status of the function.

  • msgs: Messages to be passed back to the user.

  • state: AMS state

  • session: Session object

Examples

# Within shiny the session variable will exist
# this creates examples here for testing purposes:
sess_res = ASM_test_mksession()
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders: 
#> → ASM:   -> setting docx ph: HEADERLEFT = left header
#> → ASM:   -> setting docx ph: HEADERRIGHT = right header
#> → ASM:   -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
session = sess_res$session
state   = sess_res$state

ssf  = tempfile(fileext=".zip")

ss_res = 
ASM_save_state(state, session,
               file_path = ssf)
#> → Saving module: ASM
#> → ASM: mk_preload isgood: TRUE
#> → ASM: writing app state to file on server: 
#> → ASM:   /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpxxeT0v/filebb141c6b6370.zip
#> → ASM: Generating reports (code only)
#> → ASM: done writing app state

ls_res = 
ASM_load_state(state, session,
               file_path = ssf)
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders: 
#> → ASM:   -> setting docx ph: HEADERLEFT = left header
#> → ASM:   -> setting docx ph: HEADERRIGHT = right header
#> → ASM:   -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
#> → ASM: post-processing state for module: ASM id: ASM
#> → ASM:   -> running ASM_onload() for module id: ASM