IVIM
IVIM

Reputation: 2367

Is there a way to know programatically if shiny is running?

I develop functions that take input from Shiny. However in order to test those functions, I need to run them without Shiny. So I'd like to do something like this.

---
title: "My report that prints `input` variable in both reactive and static format" 
# runtime: shiny # I want to be able programmatically to see when Shiny is running and when NOT
---

```{r}
library(shiny)
input0 <- list()
input0$typedDate <-  "6/08/1935"

if (!is.shinyRunning()) {
  print("Shiny is Not Running")
  input <- input0
} else {
  textInput("typedDate", "Enter Date:", "6 jul 1935")
}

renderPrint(input$typedDate)

Note, I tried using if (interactive()), but it returns FALSE for report both with Shiny and without Shiny.

Upvotes: 3

Views: 560

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84709

There's the isRunning function in 'shiny'.

This function tests whether a Shiny application is currently running.

Upvotes: 7

Related Questions