0

I have a Shiny-app where you can create groups and subgroups from a dataframe. Because I cannot know in in advance how many groups there will be, I also create buttons and observe-Events dynamically that allow the user to rename/delete buttons. An example would be: The user works on the iris-data and decides to make three groups: Setosa with small Petal.Length, Setosa with big Petal.Length and the rest.

Now to my problem: I also want to make it possible to save and load workflows, so that you create a predefined set of groups with their corresponding buttons (with events). Is there a way to detect all observeEvents in Shiny, so I can destroy them if they belong to no longer existing groups? I would like to do the logic for that in the R-world, but also a JS-command to get all callbacks would be highly appreciated.

Just in case you are wondering: I give meaningful names to my observeEvents so I can distinguish my custom-callbacks from other callbacks that are also present in my shinyapp.

I hope I could make clear what I mean! Please do not hesitate to ask me if there are any questions.

Noskario
  • 378
  • 1
  • 9
  • 2
    How are you creating these `observeEvents`? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. I don't think you can query all the event handlers, so it would be better to have your own data object to keep track of state that can point to different event handlers. – MrFlick Mar 03 '23 at 15:09
  • [reactlog](https://github.com/rstudio/reactlog) tracks observer somehow so you could dig into the code, though I'm guessing since you have to enable it, it creates a tracking list similar to what MrFlick is suggesting. Whenever I have dynamically created elements, I use a `reactiveVal` to keep track of them. If you looking to restore state, you might want to look into the bookmarking functionality of Shiny – Marcus Mar 03 '23 at 19:05

0 Answers0