Responding to events in JavaScript

You can listen for all kinds of events in Shiny applications, either from the window or from individual elements, and run JavaScript code when they occur. For example, you can listen for when Shiny makes the initial connection with the client, and you can listen for when Shiny is busy or idle. You can listen for when an input changes, or an output recalculates. For a full list, see the documentation at shiny.rstudio.com/articles/js-events.html. As an example, we're going to make a very simple program that takes a long time to draw a graph and gives you a little alert box when it is finished. The program is so simple that we will use the single-file app.R format. Here, it is reproduced in its entirety:

Get Web Application Development with R Using Shiny - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.