-
Notifications
You must be signed in to change notification settings - Fork 0
API.Service.EventBus
Namespace: Ju.Services
This service provides an event bus. Used by several other services as well.
You can use channels to control the events that will be fired to the subscribers. If not specified, the channel 0 will be used.
All events generated by the built-in services in this framework use the default channel 0.
void Subscribe<T>(ILinkHandler handle, Action<T> action, int priority = 0);
void Subscribe<T>(ILinkHandler handle, Action action, int priority = 0);
void Subscribe<T>(ILinkHandler handle, Action<T> action, Func<T, bool> filter, int priority = 0);
void Subscribe<T>(ILinkHandler handle, Action action, Func<T, bool> filter, int priority = 0);
void Subscribe<T>(byte channel, ILinkHandler handle, Action<T> action, int priority = 0);
void Subscribe<T>(byte channel, ILinkHandler handle, Action action, int priority = 0);
void Subscribe<T>(byte channel, ILinkHandler handle, Action<T> action, Func<T, bool> filter, int priority = 0);
void Subscribe<T>(byte channel, ILinkHandler handle, Action action, Func<T, bool> filter, int priority = 0);
void Fire<T>(T data);
void Fire<T>() where T : struct;
void Fire<T>(byte channel, T data);
void Fire<T>(byte channel) where T : struct;
void FireAsync<T>(T data);
void FireAsync<T>() where T : struct;
void FireAsync<T>(byte channel, T data);
void FireAsync<T>(byte channel) where T : struct;
void FireSticky<T>(T data);
void FireSticky<T>() where T : struct;
void FireSticky<T>(byte channel, T data);
void FireSticky<T>(byte channel) where T : struct;
void FireStickyAsync<T>(T data);
void FireStickyAsync<T>() where T : struct;
void FireStickyAsync<T>(byte channel, T data);
void FireStickyAsync<T>(byte channel) where T : struct;
T GetSticky<T>();
T GetSticky<T>(byte channel);
void ClearSticky<T>();
void ClearSticky<T>(byte channel);
void ClearAllSticky();
void StopCurrentEventPropagation();
Refs: ILinkHandler
EventFiredEvent(byte channel, Type type, string data, int subscribersCount);
You can use this interface to debug your custom events, when the event EventFiredEvent (see above) is fired the data property will contain the info returned by the Serialize method of this interface if your custom event implements it.
string Serialize();
void Subscribe<T>(byte channel, ILinkHandler handle, Action<T> action, Func<T, bool> filter, int priority = 0)
Subscribe for events in the specified channel. For methods without this parameter the default channel is 0.
The action callback won't be run if the filter returns false. Useful to filter events if its payload data doesn't meet your requirements.
Subscribers will be called in order sorted by the priority parameter (negative values will be called first [-> ...,-1,0,1,...]). If the priority value is the same they will be called in the order they subscribed.
Fires an event in the specified channel. For methods without this parameter the default channel is 0.
Fires an asynchronous event in the specified channel. For methods without this parameter the default channel is 0.
All async events will enqueue and will be fired in the next TimePostUpdateEvent tick.
Fires a sticky event in the specified channel. For methods without this parameter the default channel is 0.
The data of the last sticky event will be cached (per event type) and all new subscribers will receive automatically an event with that data when they subscribe.
Fires an asynchronous sticky event in the specified channel. For methods without this parameter the default channel is 0.
All async events will enqueue and will be fired in the next TimePostUpdateEvent tick.
The data of the last sticky event will be cached (per event type) and all new subscribers will receive automatically an event with that data when they subscribe.
Gets the data of the last sticky event fired on that channel. For methods without this parameter the default channel is 0.
Clears the data of the last sticky event fired on that channel. For methods without this parameter the default channel is 0.
Clears all sticky data for all channels.
Stops the current event propagation.
For example if you have multiple subscribers to handle a close app event, if one of those subscribers calls this method the event won't be fired in the remaining subscribers.
Return to [Home]
- Home
- Install
- Manual
-
Core API
- Services:
- Util:
-
Unity API
- Services:
- Integrations: