Interface IEvent
Represents an event which can be subscribed both synchronously or asynchorously, and is invoked asynchronously. An event is a notification for something that has happened. Interested parties can subscribe to the event and be notified when it triggers (https://en.wikipedia.org/wiki/Event-driven_programming).
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface IEvent : IDisposable
Properties
| Improve this Doc View SourceSubscribersCount
Gets the number of subscribers to the event.
Declaration
int SubscribersCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The subscribers count. |
Methods
| Improve this Doc View SourceInvokeAsync()
Invoke the event asynchronously.
Declaration
Task InvokeAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Subscribe(Action, CallbackPriority)
Subscribe the specified callback to the event. Once subscribed, whenever the event happens this callback will be called.
Declaration
void Subscribe(Action callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Action | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
SubscribeToAsync(Func<Task>, CallbackPriority)
Subscribe the specified asynchronous callback to the event. Once subscribed, whenever the event happens this callback will be called.
Declaration
void SubscribeToAsync(Func<Task> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
Unsubscribe(Action, CallbackPriority)
Unsubscribe the specified callback from the event. This will stops notifications to call this callback.
Declaration
void Unsubscribe(Action callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Action | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
UnsubscribeToAsync(Func<Task>, CallbackPriority)
Unsubscribe the specified asynchronous callback from the event. This will stops notifications to call this callback.
Declaration
void UnsubscribeToAsync(Func<Task> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
WaitUntilAsync(Func<Boolean>, CallbackPriority)
Asynchronously wait until the event fires and the specific condition applies.
Declaration
Task WaitUntilAsync(Func<bool> condition, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Boolean> | condition | The condition we are waiting to apply before moving on. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The task to be awaited. |