From 3eca88d40a563d35981224711075397165a3cc03 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:09:08 +0100 Subject: [PATCH] adds 'multi-session' to oanda_studio() --- NEWS.md | 4 ++-- R/oanda.R | 8 +++++++- man/oanda_studio.Rd | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1f4582de..8be92332 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,8 @@ # ichimoku 1.5.4.9000 (development) -#### Updates: +#### New features: -* Internal performance enhancements. +* `oanda_studio()` adds option 'multi.session' to facilitate multiple sessions to be used with the Shiny app (for example more than one browser page). # ichimoku 1.5.4 diff --git a/R/oanda.R b/R/oanda.R index dcb0a5c5..bca1b470 100644 --- a/R/oanda.R +++ b/R/oanda.R @@ -534,6 +534,10 @@ oanda_chart <- function(instrument, #' @param new.process [default FALSE] if TRUE, will start the shiny session in a #' new R process, unblocking the current process and allowing continued use #' of the R console. +#' @param multi.session [default FALSE] if TRUE, does not automatically close +#' the Shiny app when an individual session (web browser page) disconnects. +#' Use with caution in conjunction with \sQuote{new.process} as the Shiny +#' app continues to run in the background process. #' @param ... additional arguments passed along to \code{\link{ichimoku}} for #' calculating the ichimoku cloud, \code{\link{autoplot}} to set chart #' parameters, or the 'options' argument of \code{shiny::shinyApp()}. @@ -572,6 +576,7 @@ oanda_studio <- function(instrument = "USD_JPY", server, apikey, new.process = FALSE, + multi.session = FALSE, ..., launch.browser = TRUE, periods = c(9L, 26L, 52L)) { @@ -768,7 +773,8 @@ oanda_studio <- function(instrument = "USD_JPY", output$savedata <- downloadHandler(filename = function() sprintf("%s_%s_%s.rda", input$instrument, input$granularity, input$price), content = function(file) archive(pdata(), file)) - session$onSessionEnded(stopApp) + if (!multi.session) session$onSessionEnded(stopApp) + } app <- shinyApp(ui = ui, server = server, options = list(launch.browser = launch.browser, ...)) diff --git a/man/oanda_studio.Rd b/man/oanda_studio.Rd index 51321452..e0c20d03 100644 --- a/man/oanda_studio.Rd +++ b/man/oanda_studio.Rd @@ -16,6 +16,7 @@ oanda_studio( server, apikey, new.process = FALSE, + multi.session = FALSE, ..., launch.browser = TRUE, periods = c(9L, 26L, 52L) @@ -61,6 +62,11 @@ entered interactively if not specified.} new R process, unblocking the current process and allowing continued use of the R console.} +\item{multi.session}{[default FALSE] if TRUE, does not automatically close +the Shiny app when an individual session (web browser page) disconnects. +Use with caution in conjunction with \sQuote{new.process} as the Shiny +app continues to run in the background process.} + \item{...}{additional arguments passed along to \code{\link{ichimoku}} for calculating the ichimoku cloud, \code{\link{autoplot}} to set chart parameters, or the 'options' argument of \code{shiny::shinyApp()}.}