Skip to main content

Global application state and methods

Expressions

Expressions are a simple way to access data from the app runtime, or the response from server. Data is accessed through an object that is internally known as Core context or Expression context. If expression fails, it will return undefined. If you specify the default parameter, it will be returned when expression fails. Examples of expressions:

Functions

A function is another type of expression. It’s useful to add some callbacks, such as a button onClick event.

Extending Expression context

To extend expression context with custom values or methods, globals or utils configuration keys can be used:
Then in page configuration:

Expression context

Expression context is a global object, which is accessible from YAML expression only.
  • analytics - functions for trigger analytics events
  • api - information about API
  • app - information about app
Example usage of wrapByLoading
  • configuration - complete configuration of your target in json. This is an output from target-builder module, which parses all files inside target folder and produces large JSON that contains all settings, configurations, pages structures, etc.
  • constants - list of constants, the most important ones are: COUNTRIES_FULL, COUNTRIES, COUNTRY_CODES, LANGUAGES
  • cookie - methods exported from js-cookie module (cookie.get, cookie.set, cookie.remove)
  • cx - method exported from classnames module
  • device - information about device
  • flow - data from server about flow and flow/route functions from server
  • form - data about form, including states of fields
  • format - global formats used in application
  • globals - custom constants/variables, see more on how to extend expression context
  • helper - Helper functions and 3rd party libraries
  • locals - local page variables and functions
  • page - parameters of page, which may be an error. This data is set only from the local application, not the server
  • translates - function to translate a string of text, change current locale
  • url - information about locations, query params, etc.
  • utils - custom methods, see more on how to extend expression context