- 18 Aug 2022
- 1 Minute to read
- DarkLight
- PDF
Trigger Event Logic
- Updated on 18 Aug 2022
- 1 Minute to read
- DarkLight
- PDF
Introduction
Global canvas is a page that exists in the context of the whole app, meaning that logic that is present here can be accessed from all points within the app. With that in mind, we can optimize repetitive logic execution for our app and abstain from configuring the same flow multiple times.
Configuring the Global Canvas
Navigate to the Global Canvas and open the Logic canvas.
Select an unused 'Event' function or drag a new one from the 'Advanced' section of the flow functions tab. In its 'Properties' tab, change the 'Event source' to be "Fired from "Trigger event"". Expand the 'Advanced' dropdown below and choose a name for your event. It is of best practice here to choose an easily recognizable name.
If done correctly, your event should look a similar way:
From here, everything that you attach to this event will be a part of it, and thus, will be 'callable' from elsewhere in the app. For instance, you can attach a 'Delete record' flow function that removes all entries on the local database:
It is not possible to use app variables and app parameters here, as they exist only within the context of a specific page.
Calling the logic
To use the configured logic somewhere else, you need to add a "Trigger event" flow function anywhere in your app and set the 'Triggered event' property to be the name of your logic on the global canvas.
For instance, attaching the trigger event to Button's 'Component tap' creates a button that empties the local storage everytime it is pressed:
Furthermore, this logic can be re-used as much as needed via the 'Trigger event' flow function with the same settings.