Addons should subscribe to events within their exported load function.
Every time the CPI Node is loaded the subcriptions are reset, and the addon needs to resubscribe in the load function.
Subscribing is done using the pepperi.events.intercept function which recieves 3 parameters:
The event key - What event the addon wants to subscribe to
A filter object - Only subscribe to certain events
The interceptor - The function that is call when this event happens
constinterceptor: Interceptor = (data, next, main) => {// first allow other interceptors & the main action to runawaitnext(main);// perform you custom logic here}
usage
Example #3:
Implementing the main action
constinterceptor: Interceptor = (data, next, main) => {// first allow other interceptors & the main action to runawaitnext(async () => {// implement the main logic here });}
CPI Node Events
Introduction
The CPI Node allows addons to dynamically control the application's flow and layout.
This is done by exposing events that the addons can subscribe to with an Interceptor and then perform custom logic within these interceptors.
Subscribing to events
Addons should subscribe to events within their exported
load
function. Every time the CPI Node is loaded the subcriptions are reset, and the addon needs to resubscribe in theload
function.Subscribing is done using the
pepperi.events.intercept
function which recieves 3 parameters:Subscribing to the RecalculateUIObject event of the UserHomePage UIObject
Interceptors
Subscribing to events is done using the Interceptor function.
The CPI Node allows addons to control the application flow by subscribing to events.
Every event in the application is divided to 3 parts:
Addons can intercept any event and implement it's main action, and/or perform some custom logic before and/or after the main action.
The Interceptor lifecycle
See Interceptor for expamle interceptors.