What I want to do is pretty simple. I want to save all click events on a Shiny / Leaflet map. Here is a sample code:
library(raster)
library(shiny)
library(leaflet)
rwa <- getData("GADM", country = "RWA", level = 1)
shinyApp(
ui = fluidPage(
leafletOutput("map")
),
server <- function(input, output, session){
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addPolygons(data = rwa,
fillColor = "white",
fillOpacity = 1,
color = "black",
stroke = T,
weight = 1,
layerId = rwa@data$OBJECTID,
group = "regions")
})
observeEvent(input$map_shape_click, {
click <- input$map_shape_click
print(click$id)
})
})

As you can see, I can print out the click IDs (or the whole click event) when I click on the polygon. Easy enough. However, the moment I click on another polygon, all information about my first clicked polygon is lost. I see that there is an argument parameter autoDestroy = Fin observeEvent, but I'm not sure how to use it to save previously clicked polygons. Is there a way to save all my clicks / click $ ids in a vector or list?