Skip to content

Commit

Permalink
stop Shiny when session ends r-spatial#71
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Mar 7, 2018
1 parent cabd29a commit 106a643
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: mapedit
Title: Interactive Editing of Spatial Data in R
Description: Suite of interactive functions and helpers for selecting and editing
geospatial data.
Version: 0.4.1
Date: 2018-03-01
Version: 0.4.2
Date: 2018-03-07
Authors@R: c(
person("Tim", "Appelhans", role = c("aut", "cre"), email = "[email protected]"),
person("Kenton", "Russell", role = c("aut"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## mapedit 0.4.2 (develop)

* stopApp when session ended to handle when a user closes a browser tab or window when using `viewer = browserViewer(browser = getOption("browser"))`

## mapedit 0.4.1

### Bug Fix
Expand Down
11 changes: 11 additions & 0 deletions R/edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ $(document).on('shiny:disconnected', function() {
)
})

# if browser viewer and user closes tab/window
# then Shiny does not stop so we will stopApp
# when a session ends. This works fine unless a user might
# have two sessions open. Closing one will also close the
# other.
session$onSessionEnded(function() {
# should this be a cancel where we send NULL
# or a done where we send crud()
shiny::stopApp(isolate(crud()))
})

shiny::observeEvent(input$cancel, { shiny::stopApp (NULL) })
}

Expand Down
11 changes: 11 additions & 0 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ $(document).on('shiny:disconnected', function() {
})

shiny::observeEvent(input$cancel, { shiny::stopApp (NULL) })

# if browser viewer and user closes tab/window
# then Shiny does not stop so we will stopApp
# when a session ends. This works fine unless a user might
# have two sessions open. Closing one will also close the
# other.
session$onSessionEnded(function() {
# should this be a cancel where we send NULL
# or a done where we send crud()
shiny::stopApp(isolate(selections()))
})
}


Expand Down

0 comments on commit 106a643

Please sign in to comment.