Skip to content

Instantly share code, notes, and snippets.

@andrewsali
andrewsali / app.R
Last active March 7, 2018 12:02
An example to create an async drop-in replacement for eventReactive
#' An example to create asyncronously evaluated eventReactives.
library(shiny)
#' An async version of eventReactive, using the 'future' package to spawn a seperate process to evaluate the handler expression.
#' Unlike in usual eventReactive, the handlerExpr cannot have a side-effect on the main application, as it is evaluated in a seperate
#' process.
#' @param eventExpr The expression triggering the handlerExpr. It is evaluated _synchronously_.
#' @param handlerExpr The expression being calculated in async.
#' @return Returns a reactive that can be used in other reactives that depend on the async result
eventReactiveAsync <- function(eventExpr,handlerExpr,event.env = parent.frame(),handler.env=parent.frame(),...) {
@andrewsali
andrewsali / app.R
Created July 4, 2017 06:43
shinycssloaders with ggplot faceting
library(shiny)
library(shinycssloaders)
library(ggplot2)
# for spinners 2-3 match the background color of wellPanel
options(spinner.color.background="#F5F5F5")
ui <- fluidPage(
wellPanel(
tags$b("This example shows the loading spinner whilst the plot is loading and hides the spinner when the plot is not shown."),