In the following example, the text is not shown in the start. If I click on the "show"-Button the text appears. If I then click on the "hide"-Button nothing else happens anymore. In fact the "textis$visible" variable has always the correct value, but i think the if-statement in the observeEvent funktion is only calculated after the very first button click.
Is there a way to force observeEvent to re-evaluate the if statement? Or are there other ways to stop shiny from executing code in the server part and restart it again (in the real case there would be a whole bunch of function calls inside the if statement, not just hide and show some text)
library(shiny)
ui <- fluidPage(
actionButton(inputId="show","show"),
actionButton(inputId="hide","hide"),
textOutput(outputId = "some_text")
)
server <- function(input, output) {
  textis<-reactiveValues(visible=FALSE)
observeEvent(input$show,
             textis$visible<-TRUE)
observeEvent(input$hide,
             textis$visible<-FALSE)
observeEvent(textis$visible  , if(textis$visible){
  output$some_text<-renderText({"this is some text"})  
})}
shinyApp(ui = ui, server = server)