Skip to main content

Introduction

Events play a crucial role in any application or complex package as they help manage the flow of your application and make your code more readable and maintainable.

Cascade Events

In Cascade, there are various types of events triggered, including Model Events, Aggregate Events, and Query Events. Each event type has its own set of events associated with it.

In the following sections, we will explore each event type in detail.

Important Note About Events

It is essential to note that in the Event Driven Architecture concept, you must define an event before triggering it. Therefore, you cannot trigger an event that has not been defined beforehand.

Event Name Structure

Events are two types: the first one is before the operation, the second one is after the operation.

All event methods start with the prefix on, followed by the event name, and then the action mode, which can be either before or after.

Any before event is written in type followed by the ing, i.e onCreating.

Any after event is written in type followed by the ed, i.e onCreated.

Event Payload

Each event receives an object that contains the entire payload. It's important to note that the payload may vary depending on the specific event being triggered.