Grafer uses Dekkai event-emitter to emit events which can be consumed by the user.
In summary, event-emitter allows Grafer classes to inherit from an event-emitter class, which contains methods which can be used to emit and consume events within the same class. Every event emitted is associated with an ID, which identifies the type of event emitted.
Every class inheriting from event-emitter contains the on method. This method is used by the user to consume events generated by Grafer.
Parameter | Type | Description |
---|---|---|
type | symbol | string | Identifier of the type of event to listen to. |
cb | () => {} | Function to execute when an event is emitted. The arguments of the callback function are determined by the emitter and will vary from event to event. |
When a Grafer class inherits from event-emitter and has events available to consume, an "Events" section will be added to the class documentation. Each event will be listed according to type. A link will be provided indicating where the type value can be found if required. Finally a list of parameters provided to the callback function will be listed.
While the event types used are for the most part specific to each individual event-enabled Grafer class, most on methods also accept an omniEvent type, which returns all events emitted in a specific class.