Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 346
IVIM Avatar asked Nov 03 '25 00:11

IVIM


1 Answers

There's the isRunning function in 'shiny'.

This function tests whether a Shiny application is currently running.

like image 103
Stéphane Laurent Avatar answered Nov 04 '25 20:11

Stéphane Laurent