Skip to content

Commit

Permalink
fix: global var & stopApp (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceyyu authored Oct 2, 2024
1 parent 46960c5 commit 2a4bf8c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions R/gwalkr_kernel.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
utils::globalVariables(c(".rs.invokeShinyPaneViewer"))

convert_timestamps_in_df <- function(df) {
for (colname in colnames(df)) {
if (inherits(df[[colname]], "POSIXt")) {
Expand All @@ -9,7 +11,7 @@ convert_timestamps_in_df <- function(df) {

gwalkr_kernel <- function(data, lang, dark, rawFields, visConfig, toolbarExclude) {
cat("GWalkR kernel mode initialized...\n")
cat("Note: The console is unavailable while running a Shiny app. You can stop the app to use the console, or press Ctrl + C to terminate.\n")
cat("Note: The console is unavailable while running a Shiny app. You can stop the app to use the console.\n")

filter_func <- function(data, req) {
query <- parseQueryString(req$QUERY_STRING)
Expand All @@ -29,6 +31,12 @@ gwalkr_kernel <- function(data, lang, dark, rawFields, visConfig, toolbarExclude
)
}

app_options <- if (exists(".rs.invokeShinyPaneViewer")) {
c(launch.browser = .rs.invokeShinyPaneViewer)
} else {
list()
}

app <- shinyApp(
ui = fluidPage(
shinycssloaders::withSpinner(
Expand Down Expand Up @@ -63,18 +71,19 @@ gwalkr_kernel <- function(data, lang, dark, rawFields, visConfig, toolbarExclude
name = 'gwalkr',
x,
package = 'GWalkR',
width='100%',
height='100%'
width = '100%',
height = '100%'
)
})
session$onSessionEnded(function() {
cat("GwalkR closed")
duckdb_unregister_con()
stopApp()
})
},

options=c(launch.browser = .rs.invokeShinyPaneViewer)
options = app_options
)

if (interactive()) app
}
}

0 comments on commit 2a4bf8c

Please sign in to comment.