server.R

The code here is pretty simple:

observeEvent(input$buttonClick, {  js$buttonClick(input$color, input$size)})

We've seen the observeEvent() function before; it simply listens for the input$buttonClick action button. The js() function is doing all the work; it sends its arguments to the shinyjs.buttonClick function within the JavaScript file (which we will look at next). In general, js$foo sends its arguments to shinyjs.foo in the defined JavaScript.

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.