Declared Events

Declared events are events that are explicitly defined in the application model, to define a specific contract and type for the event.

Events can be declared at the Application, Flow, or Page level. References to events use prefixes, just like variables and chains.

Events may also be declared in Layouts; when used within the Layout, they behave like other Visual Builder events. But to be able to listen to a Layout event outside of the Layout, you must use the the "dynamicComponent" behavior (below).

Events have a "payloadType" which declares the type of the event payload. This type is limited to simple scalar types, or objects and arrays composed of scalar types; you cannot define a "payloadType" that references other type definitions.

Example 1-80 Declaration

"events": {
  "myPageEvent": {
    "payloadType": {
      "message": "string",
      "code": "number"
    }
  }
},

Example 1-81 Event Listener

The "page:" prefix is required only when listening outside the page, but is always recommended for clarity).

"eventListeners": {
  "page:myPageEvent": {
    "chains": [
      {
        "chainId": "handleEvent",
        "parameters": {
          "payload": "{{ $event }}"
        }
      }
    ]
  },