How to bookmark heavy calculations to avoid recalculation on restore?


I have a file input field. Upon upload and subsequent button click (eventReactive) files are processed. This step can take minutes. I would like to store the result (list with data frames as elements) and restore. So I decided to bookmark. Bookmark only restored file uploads and user inputs. Therefore, upon restore files are "uploaded" again and processed (as if the button was clicked already). This is very inefficient, as the calculations were performed already.

I tried to use onBookmark and onRestore

Save extra values in state$values when we bookmark

	onBookmark(function(state) {
		state$values$data = data
	# Read values from state$values when we restore
	onRestore(function(state) {
		data = state$values$data

However, still shiny recalculates everything. Of course this step is very predictable, hence it is reactive. But I prefer to skip it on restore. I wonder, if there is any way?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.