concept custom event in category aurelia

appears as: custom events, custom event
Aurelia in Action

This is an excerpt from Manning's book Aurelia in Action.

It’s worth mentioning that even though the binding between the books and book-list components is one-way, you can propagate the changes back up to the books view because you have a reference to the books array object. When you remove an item by index from the array, you’re removing it directly from the array of books in the parent component. This communication is achieved by object reference rather than binding. In a real-world application, you’d use a technique such as an Event Aggregator or custom events (covered in chapter 6) to notify the parent component of the change in the child component. This avoids direct object manipulation on the parent and makes the intercomponent interaction more explicit and easier to reason about.

Custom events allow you to create your own native DOM events that work like the events you’re familiar with using as part of your development process, such as click and blur. As with standard DOM events, you can also trigger these events on DOM nodes. Custom events are available via the custom-events API, a relatively recent addition to the standard web-development toolset. This API is available on modern browsers. Custom events are useful in Aurelia for the following scenarios:

6.6.2. Using custom events

You can use custom events in your JavaScript applications by following these five steps: