6

I am wondering if there is a way to detect a page change using an observer in flexdashboard with a shiny runtime environment? I would like to observe a page change then force evaluation of another observer, or, if easier, force evaluation a reactive data object inside a shiny module. The present design has a couple of graphs and stuff on the first page, all generated from the reactive dat() object, and then a leaflet map on the second page of the flexdashboard, that uses the same dat() object. The issue is that my present observer does not fire the first time a user clicks on the page, despite being setup to run via observeEvent(dat(), {plotting code here}). After they make a new data selection, however, the dat() observer fires off, thereby producing the desired results and expected leaflet plots.

I would like to solve the issue of the map being blank the first time the user clicks on the second page. I have tried looking on RStudio's docs, but maybe I have missed something. I'm hoping someone could help me with this. Thank you in advance, Nate.

nate
  • 1,172
  • 1
  • 11
  • 26

1 Answers1

0

It is difficult to say what is amiss w/o a reprex, but I would guess that the plot output is not rendered because it is on a hidden page. Maybe

outputOptions(output, "myplot", suspendWhenHidden = FALSE)

would help with myplot equal to the id of your leaflet map output object?

thothal
  • 16,690
  • 3
  • 36
  • 71
  • I tried it, but it made the map freeze and not load anything. I'm using a module to load the map (with a proxy for updates) and think I may be bumping into this issue: https://github.com/rstudio/shiny/issues/1731 ... I'll post a full `reprex` later this week as soon as I can get around to it. I really do appreciate your help. Thank you. – nate Oct 08 '18 at 23:26