Javascript API
RPGM.getCurrentStepId()
Return the id of the current step. The id is the one defined by the developer in
the .pseq
file.
RPGM.sendMessage(language, message, data = {})
Send a message to a language with some optional data.
- Language can be either
r
orpython
; - Message is a string;
- Data can be a boolean, a string, a number, an array or an object.
RPGM.getOutputURL(file)
Return a string of the URL for an output file. Mainly used in RPGM Server.
RPGM.on(message, callback)
This add 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 gracefuly clean the DOM or any Javascript code.
RPGM.off(message, callback)
Remove an event handler previously set with RPGM.on()
.