listen
  • 30 Oct 2020
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

listen

  • Dark
    Light
  • PDF

Article summary

Description

Registers specified app object(s) to listen for change events.

Token Syntax

This function uses the native app object token syntax, which refers to the ID of an object within your app that is enclosed in square brackets.

Example: [10]


Input Parameters

NameTypeRequiredDescription
tokensOrNamesTextYesComma-seperated list of app object token(s) and/or name(s)
Listening for All Input Changes

If you want to listen for ALL app object changes, you can listen for the wildcard '*' character instead of listing out all object tokens or names. An example is provided below.


Returns

No return value.


Examples

// register 3 app objects for change events
// (2 objects using object token syntax; 1 object using the object's name)
// when changed by the user, the Ux.Change event will fire
app.listen("[1], [10], favColor");
// register ALL app objects for change events
// when changed by the user, the Ux.Change event will fire
app.listen("*");

Remarks

When building apps, you will often add objects that become part of your app's visual layout. These objects are intended for user input.

By using the app.listen() function, your scripts can listen for user changes to these inputs and take appropriate action.

It is recommended that you use this function inside a script assigned to the Ux.Initialize runtime event. This script only runs once when your app is started, so it is typically the best place to setup your listeners. Then, create a seperate script assigned to the Ux.Change runtime event to take appropriate action when these inputs change.


What's Next