I read the article at "https://shiny.rstudio.com/articles/isolation.html"
Does it mean to say that with isolate() an input value will not override a previous input value, but will add to a list? Is the list being created because isolate() is being used otherwise the value of myValues$list would be overwritten and a list would not be created?
Thanks
Here is an examle:
ui <- fluidPage(
headerPanel("Test"),
textInput('txt','','Text'),
actionButton('add','add'),
verbatimTextOutput("list")
)
server <- function(input, output, session){
myValues <- reactiveValues()
observe({
if(input$add > 0){
myValues$List <- c(isolate(myValues$List), isolate(input$txt))
}
})
output$list<-renderPrint({
myValues$List
result <- receivelist(myValues$List)
value <- paste(result$myList, result$L)
value
})
}
receivelist <- function(myList){
x <- list()
myList <- append(x, myList)
L <- length(myList)
print(myList)
list(myList = myList, L = L)
}
shinyApp(ui = ui, server = server)
In your example what you are doing is preventing a dependency on either :
myValues$List
or
input$txt
...removing isolate from around myValues$List would cause your app not to not do anything.
This next one makes the role of isolate more obvious:
...removing isolate from around input$txt would cause your app to add to the list anytime text is entered after the first time "add" is pressed by causing the following observe to reevaluate every time input$text is changed :