## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----eval = FALSE-------------------------------------------------------------
# observeEvent(input$go, {
#   # 1. A callback
#   snap_restore(input$json, on_done = function(report) print(report))
# 
#   # 2. A hook that sees every restore in the session
#   snap_on_restored(function(state, report) message(nrow(report), " inputs"))
# 
#   # 3. The promise itself
#   handle <- snap_restore(input$json)
#   promises::then(handle$promise, function(report) print(report))
#   NULL
# })

## ----eval = FALSE-------------------------------------------------------------
# observeEvent(input$n, {
#   if (snap_is_restoring()) {
#     return()
#   }
#   fit()
# })
# 
# observe({
#   if (!snap_is_restoring()) fit()
# })

