Skip to content

Commit

Permalink
Merge pull request rstudio#279 from rstudio/joe/async
Browse files Browse the repository at this point in the history
Support for Shiny async
  • Loading branch information
wch committed Jun 18, 2018
2 parents c6bb033 + b66bfd2 commit 2522242
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinydashboard
Title: Create Dashboards with 'Shiny'
Version: 0.7.0
Version: 0.7.0.9000
Authors@R: c(
person("Winston", "Chang", role = c("aut", "cre"), email = "winston@rstudio.com"),
person("Barbara", "Borges Ribeiro", role = "aut", email = "barbara@rstudio.com"),
Expand All @@ -17,6 +17,7 @@ License: GPL (>= 2) | file LICENSE
Imports:
utils,
shiny (>= 1.0.0),
htmltools (>= 0.2.6)
htmltools (>= 0.2.6),
promises
BugReports: https://github.com/rstudio/shinydashboard
RoxygenNote: 6.0.1.9000
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ export(updateTabItems)
export(valueBox)
export(valueBoxOutput)
import(htmltools)
import(promises)
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
shinydashboard 0.7.0.9000
=========================

## Full changelog

### New features

* Shiny async support: render functions can now handle promises. Instead of returning a `valueBox` to `renderValueBox`, return a promise that resolves to a `valueBox` (for example).

### Bug fixes

shinydashboard 0.7.0
====================

Expand Down
13 changes: 10 additions & 3 deletions R/valueBoxOutput.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ infoBoxOutput <- valueBoxOutput
#'
#' shinyApp(ui, server)
#' }
#' @import promises
#' @export
renderValueBox <- function(expr, env = parent.frame(), quoted = FALSE) {
# Convert the expression to a function
Expand All @@ -70,10 +71,16 @@ renderValueBox <- function(expr, env = parent.frame(), quoted = FALSE) {
# send it to renderUI.
shiny::renderUI({
vbox <- vbox_fun()
tagAssert(vbox, type = "div")
if (is.promising(vbox)) {
vbox %...T>%
tagAssert(type = "div") %...>%
{ .$children[[1]] }
} else {
tagAssert(vbox, type = "div")

# Strip off outer div, since it's already present in output
vbox$children[[1]]
# Strip off outer div, since it's already present in output
vbox$children[[1]]
}
})
}

Expand Down

0 comments on commit 2522242

Please sign in to comment.