Event Emitter


yarn add @arkecosystem/core-event-emitter





Notable Dependencies


core-event-emitter wraps around NodeJS's native Event class to provide event functionality across an Ark Core node. While Ark Core uses eventemitter3 to utilize fully asynchronous event handling, the eventemitter3 API mirrors that of NodeJS's Event API, allowing Node developers to build Ark packages using familiar and extensible conventions.

Behind the Scenes

Events are used inside Ark Core to trigger blockchain actions and the delivery of webhook payloads. Additionally, custom plugins can utilize the event emitter package to trigger their own actions in response to blockchain events.

Conceptually, this feature is similar to the Hooks implementation in WordPress, as well as to the lifecycle hook access provided by JavaScript frameworks such as Vue and React. All of these systems expose The primary difference is that, because of the need for strict protocols around blockchain data creation and retrieval, Ark events are strictly reactionary. In other words, Ark Core events are not capable of changing data at runtime. The transaction.applied event, for instance, passes a complete transaction instance, not raw transaction data that can be altered in the style of a WordPress Filter.

Another way to think of the Event API is in the context of a publish-subscribe pattern. In this pattern, Ark Core packages can act both as publishers and subscribers of events.

The list of events published by Ark Core packages can be found in core-blockchain's getEvents method:

getEvents() {
  return [
Last Updated: 1/9/2019, 11:19:50 PM