An event routing system following the Publisher/Subscriber paradigm Implements the Events class
More...
|
| EventBus () |
| EventBus constructor Initialize the subscriptions dictionary
|
|
|
static void | Publish< TBusEvent > (TBusEvent busEvent) |
| Notifies and invokes callbacks on all subscribers listening for given event More...
|
|
static void | Subscribe< TBusEvent, TSubscriber > (Action< TBusEvent > callback, TSubscriber subscriber) |
| Registers subscriber for notification when the specified event is published More...
|
|
static void | Unsubscribe< TBusEvent, TSubscriber > (TSubscriber subscriber) |
| Remove subscription representing association between subscriber and the given event type Note: To avoid memory issues, make sure that objects unsubscribe before they are destroyed, sleep, etc. More...
|
|
static void | ClearSubscriptions () |
| Clears all the subscriptions that are attached to the EventBus.
|
|
|
static EventBus | Instance [get] |
| A static instance of EventBus which maintains event / subscriber + callback associations only indirectly accessible through the Publish/Subscribe/Unsubscribe methods
|
|
An event routing system following the Publisher/Subscriber paradigm Implements the Events class
◆ Publish< TBusEvent >()
static void Astra.Utils.EventBus.Publish< TBusEvent > |
( |
TBusEvent |
busEvent | ) |
|
|
inlinestatic |
Notifies and invokes callbacks on all subscribers listening for given event
- Template Parameters
-
TBusEvent | Type of event to publish |
- Parameters
-
busEvent | Instance of the event item to publish |
◆ Subscribe< TBusEvent, TSubscriber >()
static void Astra.Utils.EventBus.Subscribe< TBusEvent, TSubscriber > |
( |
Action< TBusEvent > |
callback, |
|
|
TSubscriber |
subscriber |
|
) |
| |
|
inlinestatic |
Registers subscriber for notification when the specified event is published
- Template Parameters
-
TBusEvent | Type of event to publish |
TSubscriber | Type of subscriber |
- Parameters
-
callback | Callback to be invoked on publication of given event |
subscriber | A reference to the subscribing Object |
- Type Constraints
-
TBusEvent | : | BusEvent | |
TSubscriber | : | UnityEngine.Object | |
◆ Unsubscribe< TBusEvent, TSubscriber >()
static void Astra.Utils.EventBus.Unsubscribe< TBusEvent, TSubscriber > |
( |
TSubscriber |
subscriber | ) |
|
|
inlinestatic |
Remove subscription representing association between subscriber and the given event type Note: To avoid memory issues, make sure that objects unsubscribe before they are destroyed, sleep, etc.
- Template Parameters
-
TBusEvent | Type of event to which to unsubscribe |
TSubscriber | Type of subscriber |
- Parameters
-
subscriber | A reference to the subscribed Object |
- Type Constraints
-
TBusEvent | : | BusEvent | |
TSubscriber | : | UnityEngine.Object | |
The documentation for this class was generated from the following file:
- Assets/Astra/Utilities/EventBus.cs