Interface IEventBus
The service for managing events and event subscriptions.
Namespace: OpenMod.API.Eventing
Assembly: OpenMod.API.dll
Syntax
public interface IEventBus
Methods
| Improve this Doc View SourceEmitAsync(IOpenModComponent, Nullable<Object>, IEvent, EventExecutedCallback)
Emits an event.
Declaration
Task EmitAsync(IOpenModComponent component, object? sender, IEvent event, EventExecutedCallback callback = null)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component emitting the event. |
System.Nullable<System.Object> | sender | The object emitting the event. |
IEvent | event | The event object. |
EventExecutedCallback | callback | The optional event callback. See EventExecutedCallback. |
Returns
Type | Description |
---|---|
Task |
Subscribe(IOpenModComponent, Assembly)
Finds and registers all IEventListeners.
Declaration
IDisposable Subscribe(IOpenModComponent component, Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component registering the event listeners. |
Assembly | assembly | The assembly to search for event listeners in. |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the event listeners when disposed. |
Subscribe(IOpenModComponent, String, EventCallback)
Subscribes a component to an event.
Declaration
IDisposable Subscribe(IOpenModComponent component, string eventName, EventCallback callback)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component. |
System.String | eventName | The event to subscribe to. |
EventCallback | callback | The action to execute. See EventCallback |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the callback when disposed. |
Subscribe(IOpenModComponent, String, EventCallback, IEventListenerOptions)
Subscribes a component to an event.
Declaration
IDisposable Subscribe(IOpenModComponent component, string eventName, EventCallback callback, IEventListenerOptions options)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component. |
System.String | eventName | The event to subscribe to. |
EventCallback | callback | The action to execute. See EventCallback |
IEventListenerOptions | options | The extended options for this event subscription. |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the callback when disposed. |
Subscribe(IOpenModComponent, Type, EventCallback)
Declaration
IDisposable Subscribe(IOpenModComponent component, Type eventType, EventCallback callback)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component. |
Type | eventType | The event to subscribe to. |
EventCallback | callback | The action to execute after all listeners were notified. |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the callback when disposed. |
Subscribe(IOpenModComponent, Type, EventCallback, IEventListenerOptions)
Declaration
IDisposable Subscribe(IOpenModComponent component, Type eventType, EventCallback callback, IEventListenerOptions options)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component. |
Type | eventType | The event to subscribe to. |
EventCallback | callback | The action to execute after all listeners were notified. |
IEventListenerOptions | options | The extended options for this event subscription. |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the callback when disposed. |
Subscribe<TEvent>(IOpenModComponent, EventCallback<TEvent>)
Declaration
IDisposable Subscribe<TEvent>(IOpenModComponent component, EventCallback<TEvent> callback)
where TEvent : IEvent
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component. |
EventCallback<TEvent> | callback | The action to execute after all listeners were notified. |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the callback when disposed. |
Type Parameters
Name | Description |
---|---|
TEvent | The event to subscribe to. |
Subscribe<TEvent>(IOpenModComponent, EventCallback<TEvent>, IEventListenerOptions)
Declaration
IDisposable Subscribe<TEvent>(IOpenModComponent component, EventCallback<TEvent> callback, IEventListenerOptions options)
where TEvent : IEvent
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component. |
EventCallback<TEvent> | callback | The action to execute after all listeners were notified. |
IEventListenerOptions | options | The extended options for this event subscription. |
Returns
Type | Description |
---|---|
IDisposable | A disposable that unsubscribes the callback when disposed. |
Type Parameters
Name | Description |
---|---|
TEvent | The event to subscribe to. |
Unsubscribe(IOpenModComponent)
Unsubscribes a component from all events.
Declaration
void Unsubscribe(IOpenModComponent component)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component owning the event listeners. |
Unsubscribe(IOpenModComponent, String)
Unsubscribes a component from an event.
Declaration
void Unsubscribe(IOpenModComponent component, string eventName)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component unsubscribing. |
System.String | eventName | The event to unsubscribe from. |
Unsubscribe(IOpenModComponent, Type)
Unsubscribe a component from an event.
Declaration
void Unsubscribe(IOpenModComponent component, Type eventType)
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component unsubscribing. |
Type | eventType | The event to unsubscribe from. |
Unsubscribe<TEvent>(IOpenModComponent)
Unsubscribes a component from an event.
Declaration
void Unsubscribe<TEvent>(IOpenModComponent component)
where TEvent : IEvent
Parameters
Type | Name | Description |
---|---|---|
IOpenModComponent | component | The component unsubscribing. |
Type Parameters
Name | Description |
---|---|
TEvent | The event to unsubscribe from. |