API. WEBDATAMONITOR

The API.WEBDATAMONITOR namespace provides a set of interfaces for easily and quickly adding webdata monitoring and processing transactions. The webdata variable can be added under the container component (behavior --> Add variable), and the variable can be used in the code editor. This API allows you to monitor changes to webdata variables and update their values. This API is ideal for situations where you want stateful management, but don't want to use RAPID variables.

Methods

getWebdata(keyopt) → {Promise.<object>}

Gset the webdata's value.

Parameters:
NameTypeAttributesDescription
keystring<optional>

The key name of the webdata.

Returns:

The webdata value.

Type: 
Promise.<object>
Example
const webdataMode = API.WEBDATAMONITOR.getWebdata("App.page.LayoutInfo_1.mode");
console.log(webdataMode)

monitorWebdata(keyopt, callbackopt)

Subscribes to a webdata.

Parameters:
NameTypeAttributesDescription
keystring<optional>

The webdata name.

callbackfunction<optional>

The callback function that is called when the webdata changes.

Example
API.WEBDATAMONITOR.monitorWebdata(
 "App.page.LayoutInfo_1.mode",
 (v)=>{
   console.log(v);
 }
)

setWebdata(keyopt, valueopt)

Updates the value of a specified webdata.

Parameters:
NameTypeAttributesDescription
keystring<optional>

The webdata name.

valuestring<optional>

The value to be updated.

Example
API.WEBDATAMONITOR.setWebdata(
 "App.page.LayoutInfo_1.mode",
  "manual"
)