logo
logo

External component events

In an external page component's code, you can subscribe to events occurring within the system.

This section lists the available events and describes how to subscribe to them, for the page mediator and the component mediator.

Page mediator

The following events are available:

  • Entity events:

    EventDescriptionEvent Data
    entityUpdated (id)Fired when the entity (id) is updated.Entity object
    entityCreatedFired when an entity is created.Entity object
    entitySaved (id)Fired when the entity (id) is saved.Entity object
    entityRefreshed (id)Fired when the entity (id) is refreshed.Entity object
    entityChanged (id) / property (propertyName)Fired when the property (propertyName) is changed on the entity (id)Property value
  • Realtime events:

    EventDescriptionEvent Data
    realtime (notificationType)Fired when a real-time notification is receivednotification parameters

To subscribe to an event, use the following code:

var entityLoadedSubscription = options._page.mediator.subscribe("{event's name}:{entity id}", function (entity) {
    //User code
    });

Examples:

var entityLoadedSubscription = options._page.mediator.subscribe("entitySaved:1234", function (entity) {
    //User code
    });
var entityLoadedSubscription = options._page.mediator.subscribe("entityChanged:1234:property:Title", function (property_value) {
    //User code
    });

Component mediator

The following events are available:

  • Entity events:

    EventDescriptionEvent Data
    entityLoadedFired when the page entity is loaded.Event data = Entity object
    entityUnloadedFired when the page entity is unloaded.

To subscribe to an event, use the following code:

var entityLoadedSubscription = options.mediator.subscribe("{event's name}", function (entity) {
    //User code
    });

Example:

var entityLoadedSubscription = options.mediator.subscribe("entityLoaded", function (entity) {
    //User code
    });

Can we improve this article ? Provide feedback