0
옵저버를 사용하여 전역 변수를 업데이트하려면 어떻게해야합니까? 반짝이는 관찰자 - 옵저버를 사용하여 전역 변수를 업데이트하는 방법?
나는 시작의 빈 종이 :speciesChoices <- c()
을하지만 뭔가가 UI로 변경되면 그것으로 값을 추가 할, 그래서됩니다 : 가능
speciesChoices <- c(
'PM2.5' = 'particles'
)
인가? 지금까지
내 코드 ...
ui.r :
speciesOptions <- selectInput(
inputId = "species",
label = "Species:",
choices = c(
# 'PM2.5' = 'particles',
# 'Humidity %' = 'humidity'
)
)
server.r : 그것은 단지 UI로 입력을 업데이트
speciesChoices <- c() # global variable
# Define server logic required to draw a histogram
shinyServer(function(input, output, session) {
observe({
key <- input$streams1
stream <- fromJSON(paste(server, "/output/stream?public_key=", key, sep=""),flatten=TRUE)
species <- as.data.frame(stream$species)
# Set choices of title and code for select input.
speciesChoices <- setNames(species$code_name, species$public_name)
updateSelectInput(session, "species", choices = speciesChoices)
})
})
아니라 speciesChoices에 서버.
어떤 아이디어가 있습니까?