Subscribe to component events
Entity events:
Realtime events:
* copied from Sitecore Content Hub docs
Once in a while, you have a requirement that you just can solve with the standard components within Content Hub. Luckily for us, Content Hub supports External components. This allows us to integrate external libraries within the Content Hub. It provides us with flexibility and allows advanced customization.
When creating such a component, you may find yourself in a bit of a pickle. How do you know when the entity on the page has been loaded, changed, etc. Well, Sitecore has come up with the use of events that you can subscribe to.
Here are some coding examples
var entityLoadedSubscription = options.mediator.subscribe("entityLoaded", function (entity) { // do action }); var entityUnloadedSubscription = options.mediator.subscribe("entityUnloaded", function (entity) { // do action });
Event | Description | Event Data |
---|---|---|
entityUpdated (id) | Fired when the entity (id) is updated. | Entity object |
entityCreated | Fired 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:
Event | Description | Event Data |
---|---|---|
realtime (notificationType) | Fired when a real-time notification is received | notification parameters |