Breadcrumb
Events
What are events?
SDK allows access to SR360 event bus. You can use it to communicate between system components.
Overall description about Service can be found in EventBusService.
SDK Public Events
SDK shares the following public events that can be handled by EventBusService
.
Extension Point abort event
This event is triggered whenever flow is canceled from extension point.
In order to be used, the event type and data model have to be imported:
import {EXTENSION_POINT_ABORT_EVENT} from 'sabre-ngv-sdk-events/events';
import {ExtPointAbortEventData} from 'sabre-ngv-sdk-events/interfaces/ExtPointAbortEventData';
To find out more about this event check handling workflow abort event article.
New user sign-in event
This event is triggered whenever a user logs in, it has no data model.
In order to be used, the event type has to be imported:
import {SIGN_IN_EVENT} from 'sabre-ngv-sdk-events/events';
Copy to PNR executed
This event is triggered whenever copying data to PNR finishes, it has no public type and no data model.
In order to be used, the event type has to be imported:
import {COPY_TO_PNR_EXECUTED_EVENT} from 'sabre-ngv-sdk-events/events';
PNR Session Updated event
This event is triggered whenever active PNR record locator has been changed.
In order to be used, the event type and data model have to be imported:
import {PNR_SESSION_UPDATED_EVENT} from 'sabre-ngv-sdk-events/events';
import {PnrSessionUpdatedEventData} from 'sabre-ngv-sdk-events/interfaces/PnrSessionUpdatedEventData';
Here is a list of parameters that a listener to this event should have:
Parameter | Description |
---|---|
|
Currently active area. |
|
Currently active PNR record locator. |
Area changed event
This event is trigger whenever the working area is changed.
In order to be used, the event type will have to be imported:
import {AREA_CHANGED_EVENT} from 'sabre-ngv-sdk-events/events';
Here is a list of parameters that a listener to this event should have:
Parameter | Description |
---|---|
|
Name of the new area. |
|
PCC in the new area. |
Additional information
Instruction on how to handle these events can be found in Registering an event handler section.
Custom Events
EventBusService
gives possibility to send and handle custom events, which allows to create communication and transfer data between various components and Red Apps.
Be aware that event bus is global and shared between core SR360 events and all Red Apps, so to avoid confusion all events triggered by a Red App have to be prefixed with the Red App name.
Using Events
Sending event
EventBusService
can be used to send an event, with the triggerOnEventBus
method.
Example of sending custom event in a proper way:
import {EventBusService} from 'sabre-ngv-app/app/services/impl/EventBusService';
const eb: EventBusService = getService(EventBusService);
eb.triggerOnEventBus('com-sabre-redapp-example3-web-eventbus-trigger-sample-event',
{
data: 'Hi there!'
}
);
Registering an event handler
To register an event handler use listenToEventBus
method from EventBusService
.
Note
|
In case you want to handle event once use the listenToEventBusOnce method instead.
|
Example of handling custom com-sabre-redapp-example3-web-eventbus-trigger-sample-event event created in previous section and PNR session updated event from SR360 defined events:
import {EventBusService} from 'sabre-ngv-app/app/services/impl/EventBusService';
import {PNR_SESSION_UPDATED_EVENT} from 'sabre-ngv-pnr-session-updated-event-trigger/types/PNR_SESSION_UPDATED_EVENT';
import {PnrSessionUpdatedEventData} from 'sabre-ngv-pnr-session-updated-event-trigger/interfaces/PnrSessionUpdatedEventData';
const eb: EventBusService = getService(EventBusService);
eb.listenToEventBus('com-sabre-redapp-example3-web-eventbus-trigger-sample-event', (data) => {
console.log('Message from event: ', data);
});
eb.listenToEventBus(PNR_SESSION_UPDATED_EVENT, (data: PnrSessionUpdatedEventData) => {
console.log('Message from PNR session updated event: ', data);
})
Sample implementation
See com.sabre.redapp.example3.web.eventbus.handler and com.sabre.redapp.example3.web.eventbus.trigger samples for implementation.