Simple AJAX system for Shiny apps (JS -> R -> JS communication)
Using this system is easy:
api.jsin your Shiny app's UI
api.Rin your Shiny app's server
paramsis an object that contains all the parameters as key-value pairs. You must specify the
_methodparameter -- this is the R function that will get called. For example, if in R you defined a function
api.call('_method' : 'myfunc')(notice that the prefix
api.is ommitted). You can optionally provide
_failureCallbackfunctions which can be called when the R function completes or when it throws an error. You can also add any other arbitrary parameters, and they will be available to you in the R function.
This may sound a bit complicated, but if you take a look at the source code of the sample app you'll see it's actually pretty simple to use.