Posted on Leave a comment


You can use JavaScript to extend the ability of LanceX.

Public API

$done() function

Since all scripts run asynchronously, $done() should be called to indicate completion, even for scripts that do not require results. Otherwise, the script will print a warning due to a timeout.

Basic Information

  • $lancex

The object means that you are in the environment of LanceX.

Persistent Store

  • $persistentStore.write(data<String>, [key<String>])

Save data permanently. Only a string is allowed

  • $[key<String>])

Get the saved data. Return a string or null.

Http Request

  • $<String> or options<Object>, callback<Function>)

Start an HTTP POST request. The first parameter can be a URL or object. An example object may look like that.

    url: "",
    headers: {
        "Content-Type": "application/json"
    body: "{}",
    timeout: 5,
    callback: callback(error, response, data) {


The url is always required. body can be a string or object. When presenting an object, it is encoded to JSON string, and the Content-Type is set to application/json automatically.

Similar function: $httpClient.get, $httpClient.put$httpClient.delete, $httpClient.head, $httpClient.options, $httpClient.patch.

  • fetch(URL<String>, options<Object>)

It’s an implementation of Fetch API, for example

    method: "POST",
    headers: {
        "Content-Type": "application/json"
    body: "{}"


  • console.log(message<String>)

Log to LanceX logfile. Similar function: console.warn, console.error,

  • setTimeout(function[, delay])

Same as the setTimeout in browsers. Similar function: setInterval.

  • $<String>, subtitle<String>, body<String>, info<Object>)

Post a notification. Please turn on Allow Notifications before using it. info allows you to open a url when user clicks the notification. For example:

   "open-url" : ""
Leave a Reply

Your email address will not be published. Required fields are marked *