Board state can be preserved by serializing all contained objects and
restored via de-serialization. This mechanism can be used to power features
such as save/restore (via download, as implemented in the default
preserve_board plugin), but more refined user experience is conceivable
in terms of undo/redo functionality and (automatic) saving of board state.
Such enhancements can be implemented in a third-party preserve_board
module.
preserve_board(server = preserve_board_server, ui = preserve_board_ui)preserve_board_server(id, board, ...)
restore_board(x, new, result, ..., session = get_session())
preserve_board_ui(id, board)
serialize_board(x, blocks, id = NULL, ..., session = get_session())
A plugin container inheriting from preserve_board is returned by
preserve_board(), while the UI component (e.g. preserve_board_ui()) is
expected to return shiny UI (i.e. shiny::tagList()) and the server
component a shiny::reactiveVal() evaluating to NULL or the board to
restore.
Server/UI for the plugin module
Namespace ID
The initial board object
Extra arguments passed from parent scope
The current board object
Serialized (list-based) representation of the new board
A shiny::reactiveVal() to hold the new board object
Shiny session
Block state reactive values
The session$reload() that a restore triggers is handled by the app's
board_loader() (passed to serve()), not by the plugin -- the plugin
server simply returns the board to restore and never reloads.