Native JavaScript SDK Reference

 

 


ESLib

The main object used to interact with the EachScape runtime defines several methods that allow you to interact with EachScape Variables and execute Actions.

 

Supported on

 

  • iOS 

 

Methods

  • getVar(variableName)

    • Description

      • Retrieves the values of EachScape variables

    • Parameters

      • variableName: A string representing the name of the EachScape Variable to retrieve

    • Return Value

      • The current value of the request EachScape Variable

    • Notes

      • The same functionality can be achieved using the expandTemplate method. In other words, ESLib.getVar('myVariable') is equivalent to ESLib.expandTemplate('var:myVariable') (see expandTemplate)

  • setVar(variableName, value)

    • Description

      • Sets EachScape variables, which are available through the app by using the [[var:<variableName>]] template expander.

    • Parameters

      • variableName: The name of the EachScape Variable who value should be set.

      • value: the new value that the EachScape Varaible will be set to

    • Return Value

      • None

  • expandTemplate(expression)

    • Description

      • Used to access EachScape Template Expanders and Formatters

    • Parameters

      • template: The template expression to evaluate. This is the part of a template between the “[[” and “]]” and can be used to access variables, sys values, data source values, formatters and anything else you could normally use a template expression for

    • Return Value

      • A string representing the value of the evaluated template.

    • Example

      • var halfDeviceHeight = ESLib.expandTemplate('sys:deviceAvailableViewHeight:div 2'); // Sets the javascript variable halfDeviceHeight to half of the current height of the user’s device.

    • Notes

      • expandTemplate always returns a string.

  • executeAction(settings)

    • Description

      • Executes EachScape Actions.

    • Parameters

      • settings: A javascript object whose properties correspond to the configuration values of the action to be execute. The property “action” should always be included; which other properties are required depend on the particular action to be executed.

    • Return Value

      • A boolean value indicating if the action was executed or not.

    • Example

      • ESLib.executeAction({action: 'alert', prompt: 'Hi there'}); // Executes the Show Alert Popup with “Hi there” as the text of the alert popup.

  • logInfo(message)

    • Description

      • Logs messages to the device log. These messages can be viewed in the EachScape Inspector and can be helpful for debugging.

    • Parameters

      • message: the message to print in the device logs

    • Return Value

      • None 


Tutorial App

A Tutorial app which uses ESLib to execute EachScape ESLib:

Install Script in JavaScript Tutorial App