Javascript API
RPGM.getCurrentStepId()
Returns the id of the current step. The id is the one defined by the developer in
the .pseq file.
RPGM.sendMessage(language, message, data = {}, options = {})
Sends a message to a language with some optional data.
- Language can be either
rorpython; - Message is a string;
- Data can be a boolean, a string, a number, an array, or an object.
- Options is an optional parameter of an object which can contain the following properties:
rArrayTypecan take as values"vector","list"or"auto", and will control how JS arrays will be converted to R."auto"will convert any array containing data of the same primitive type to a vector, and a list otherwise.
RPGM.getOutputURL(file)
Returns a string of the URL for an output file. Mainly used in RPGM Server.
RPGM.on(message, callback)
Adds a new custom handler for RPGM events.
Currently there are 4 events fired:
didEnterStep(customStepId)is emitted when entering in a new step in the app. This event is guaranteed to be emitted only once and will be emitted one time after all the custom Javascript and CSS files are loaded;didReceiveMessage(message, data, language)is emitted when receiving a packet from R or Python sent withrpgm.sendToJavascript;willLeaveStep(customStepId)is emitted when exiting a step. This should be used for cleaning the DOM or any Javascript code;willDispose()is emitted when quitting the app. This should be used to gracefully clean the DOM or any Javascript code.
RPGM.off(message, callback)
Removes an event handler previously set with RPGM.on().