In a typical life-cycle of Events:
- A user action triggers an event for the variable.
- The event action talks to the data source via the API call.
- The result from API call is reflected in the Data which in turn changes the user data view.
Four actions can be said to be responsible for triggering a variable life-cycle:
- Request data on page load is a property that can be set for every variable. This can be used to initialize and fetch Live Variable data during page load.
- Pagination - Live Variable results are paginated and page size can be configured based on the app needs.
- Events - Widgets are updated/notified by user events like click, submit, or variable events like pre and post update, on error etc..
- Update data on input change is a property which configures the ability to auto-reload Variable data, for example, if the data filter value changes dynamically from city = ‘New York’ to city = ‘Boston.
During the life cycle of a Variable, a set of events are emitted by the Variable, thus giving you the option to control the behavior of the Variable such as input data validations, data processing, success/error handling, etc.
A typical event flow when a variable is used to update data would be:
The onBeforeUpdate event in the above diagram differs based upon the type of variable as explained in the table below. It is:
- onBeforeListRecords for Database CRUD Variable with READ operation
- onBeforeUpdateRecord for Database CRUD Variable with UPDATE operation
- onBeforeInsertRecord for Database CRUD Variable with INSERT operation
- onBeforeDeleteRecord for Database CRUD Variable with DELETE operation
- onBeforeUpdate for all types of variables except Database CRUD Variable
For more information, see Events.