有没有办法以编程方式知道闪亮是否正在运行?

时间:2020-11-12 22:08:36

标签: r shiny r-markdown

我开发了一些功能,这些功能取自Shiny input。但是,为了测试这些功能,我需要在没有Shiny的情况下运行它们。所以我想做这样的事情。

---
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)

请注意,我尝试使用if (interactive()),但对于有光泽和无光泽的报告,它都返回FALSE。

1 个答案:

答案 0 :(得分:1)

“光泽”中有isRunning函数。

此功能测试Shiny应用程序当前是否正在运行。