EventHub Events

EventHub overview

The EventHub helper class resolves the Sitefinity CMS event service. Event service is a mechanism that lets you easily subscribe to multiple events raised by the Sitefinity CMS modules and execute custom code when they are fired. The service provides a centralized entry point for working with a large collection of default Sitefinity events, as well as for creating custom events.

IEventService and EventHub

The Event Service is meant to be a central and uniform mechanism that allows event publishers/producers to talk to event subscribers/consumers. Its interface (IEventService) is a variation of the classic publish/subscribe pattern and the system implementation can be obtained by resolving the interface from the ObjectFactory.

Resolving the implementation this way allows its replacement with a custom one, in case this is needed. However, in most cases you can use the default implementation. To make the usage of the Event Service easier in the most common scenarios, the EventHub helper class is introduced, which always resolves the event service implementation and lets it do the real work.

NOTE: You should be careful with custom code when subscribing to events from EventHub. Once the SiteSync is completed, you should be careful not to trigger the events later, as this will cause problems. For example, if you subscribe to the IDynamicContentUpdatedEvent, you must not republish the dynamic content item on the production environment, because this will trigger the event and could cause unexpected behavior.

Was this article helpful?

Next article

Bootstrapper Events