Skip to content

Commit

Permalink
Asynchronously register plot events
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Aug 30, 2019
1 parent af1c770 commit 3867737
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) {

# Converts a plot, OR a promise of a plot, to plotly
prepareWidget <- function(x) {
p <- if (promises::is.promising(x)) {
promises::then(x, plotly_build)
if (promises::is.promising(x)) {
promises::then(
promises::then(x, plotly_build),
register_plot_events
)
} else {
plotly_build(x)
register_plot_events(plotly_build(x))
}
register_plot_events(p)
p
}

register_plot_events <- function(p) {
Expand All @@ -83,6 +84,7 @@ register_plot_events <- function(p) {
session$userData$plotlyShinyEventIDs,
eventIDs
))
p
}


Expand Down

0 comments on commit 3867737

Please sign in to comment.