Class Facades.Events

The Events class is a layer between World of Warcraft events and events triggered by the Stormwind Library.

When using this library in an addon, it should focus on listening to the library events, which are more detailed and have more mapped parameters.

Local Functions

facades.events.createFrame () Creates the events frame, which will be responsible for capturing all World of Warcraft events and forwarding them to the library handlers.
facades.events.playerTargetChangedListener () Listens to the World of Warcraft PLAYER_TARGET_CHANGED event, which is triggered when the player changes the target.

Methods

facades.events:handleOriginal (source, event, ...) This is the main event handler method, which will capture all subscribed World of Warcraft events and forwards them to the library handlers that will later notify other subscribers.
facades.events:listen (event, callback) Listens to a Stormwind Library event.
facades.events:listenOriginal (event, callback) Sets the Events Frame to listen to a specific event and also store the handler callback to be called when the event is triggered.
facades.events:notify (event, ...) Notifies all listeners of a specific event.

Metamethods

facades.events:__construct () Events constructor.


Local Functions

Methods
facades.events.createFrame ()
Creates the events frame, which will be responsible for capturing all World of Warcraft events and forwarding them to the library handlers.
facades.events.playerTargetChangedListener ()
Listens to the World of Warcraft PLAYER_TARGET_CHANGED event, which is triggered when the player changes the target.

This method breaks the event into three different events:

- PLAYER_TARGET: triggered when the player targets a unit - PLAYER_TARGET_CHANGED: triggered when the player target changes - PLAYER_TARGET_CLEAR: triggered when the player clears the target

To achieve this, a pleyerHadTarget event state is used to keep track of whether the player had a target or not when the World of Warcraft event was captured.

When the player had no target and the event was captured, the PLAYER_TARGET is triggered, meaning that player now targetted a unit.

When the player had a target, the event was captured and the player still had a target, the PLAYER_TARGET_CHANGED is triggered, meaning that it was changed.

Finally, when the player had a target and the event was captured, but the player no longer has a target, the PLAYER_TARGET_CLEAR is triggered.

Methods

facades.events:handleOriginal (source, event, ...)
This is the main event handler method, which will capture all subscribed World of Warcraft events and forwards them to the library handlers that will later notify other subscribers.

It's important to mention that addons shouldn't care about this method, which is an internal method to the Events class.

Parameters:

  • source table The Events instance, used when calling Events.handleOriginal
  • event string The World of Warcraft event to be handled
  • ... The parameters passed by the World of Warcraft event
facades.events:listen (event, callback)
Listens to a Stormwind Library event.

This method is used by addons to listen to the library events.

Parameters:

  • event string The Stormwind Library event to listen to
  • callback function The callback to be called when the event is triggered
facades.events:listenOriginal (event, callback)
Sets the Events Frame to listen to a specific event and also store the handler callback to be called when the event is triggered.

It's important to mention that addons shouldn't care about this method, which is an internal method to the Events class.

Parameters:

  • event string The World of Warcraft event to listen to
  • callback function The callback to be called when the event is triggered
facades.events:notify (event, ...)
Notifies all listeners of a specific event.

This method should be called by event handlers to notify all listeners of a specific Stormwind Library event.

Parameters:

  • event string The Stormwind Library event to notify
  • ... The parameters to be passed to the event listeners

Metamethods

facades.events:__construct ()
Events constructor.
generated by LDoc 1.5.0 Last updated 2024-09-11 16:27:53