You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Austen McDonald edited this page Nov 11, 2016
·
1 revision
Events are a way for modules and parts of the core to communicate with each other
without having to know exactly what communication should take place. Events are
represented by strings. There are a
number of uses for events, with these rough naming conventions:
e/[vendor]/[module]/[event-name]: Simple announcement events, just saying
that something has occurred. Possible Examples:
e/lotgd/core/startup.
h/[vendor]/[module]/[event-name]: Hooks, or events that are designed to
seek input from other parts of the system (like modules). Possible examples:
h/lotgd/core/get-attack-value.
a/[vendor]/[module]/[event-name]: Analytic events, those only for tracking
purposes. Possible examples: a/lotgd/core/startup-perf, a/lotgd/core/motd-new.
Events are handled by a class that implements the EventHandler interface and
has been previously subscribed to events by calling $game->getEventManager()->subscribe().
Subscriptions use regular expressions: subscribers provide a regex
to match against event names and any published event that matches the regex
triggers a call to the class's handleEvent() method. See the Sample Crate and
the Hello World Module for an example.
Events are published via $game->getEventManager()->publish() and can pass an
array() which represents the context of the event. This array() is a so-called
"in-out" variable, so changes made to the array() in handleEvent() calls will
be visible to the publisher. This is how hooks will communicate their input to
the publisher.