Skip to content

Interface IEventService

Namespace: Void.Proxy.Api.Events.Services
Assembly: Void.Proxy.Api.dll

Publishes proxy events and manages objects that contain subscribed event handlers.

public interface IEventService

Remarks

Handlers run in order. Player-scoped events are filtered against scoped listeners unless the handler’s value is enabled.

Properties

Listeners

Gets a snapshot of listener entries currently registered with the service.

IEnumerable<IEventListener> Listeners { get; }

Property Value

IEnumerable<IEventListener>

Methods

RegisterListeners(IEnumerable<IEventListener>, CancellationToken)

Registers subscribed methods from a sequence of listener objects.

void RegisterListeners(IEnumerable<IEventListener> listeners, CancellationToken cancellationToken = default)

Parameters

listeners IEnumerable<IEventListener>

The listeners to inspect and register.

cancellationToken CancellationToken

A token linked to handler invocations for these registrations.

RegisterListeners(CancellationToken, params IEventListener[])

Registers subscribed methods from listener objects with an invocation cancellation token.

void RegisterListeners(CancellationToken cancellationToken = default, params IEventListener[] listeners)

Parameters

cancellationToken CancellationToken

A token linked to handler invocations for these registrations.

listeners IEventListener[]

The listeners to inspect and register.

RegisterListeners(params IEventListener[])

Registers subscribed methods from listener objects without a registration cancellation token.

void RegisterListeners(params IEventListener[] listeners)

Parameters

listeners IEventListener[]

The listeners to inspect and register.

ThrowAsync<T>(CancellationToken)

Constructs and publishes an event.

ValueTask ThrowAsync<T>(CancellationToken cancellationToken = default) where T : IEvent, new()

Parameters

cancellationToken CancellationToken

A token linked to the token passed to asynchronous handlers.

Returns

ValueTask

A task that completes after eligible handlers have run.

Type Parameters

T

The event type to construct and publish.

ThrowAsync<T>(T, CancellationToken)

Publishes an existing event instance.

ValueTask ThrowAsync<T>(T @event, CancellationToken cancellationToken = default) where T : IEvent

Parameters

event T

The event instance to publish.

cancellationToken CancellationToken

A token linked to the token passed to asynchronous handlers.

Returns

ValueTask

A task that completes after eligible handlers have run.

Type Parameters

T

The event type.

ThrowWithResultAsync<TResult>(IEventWithResult<TResult>, CancellationToken)

Publishes an event and returns the result left by its handlers.

ValueTask<TResult?> ThrowWithResultAsync<TResult>(IEventWithResult<TResult> @event, CancellationToken cancellationToken = default)

Parameters

event IEventWithResult<TResult>

The event instance to publish.

cancellationToken CancellationToken

A token linked to the token passed to asynchronous handlers.

Returns

ValueTask<TResult?>

The final value of the event’s result property. For nullable result types, this can be null when no handler assigns a value.

Type Parameters

TResult

The event result type.

ThrowWithResultAsync<T, TResult>(CancellationToken)

Constructs and publishes a result-bearing event, then returns its result.

ValueTask<TResult?> ThrowWithResultAsync<T, TResult>(CancellationToken cancellationToken = default) where T : IEventWithResult<TResult?>, new()

Parameters

cancellationToken CancellationToken

A token linked to the token passed to asynchronous handlers.

Returns

ValueTask<TResult?>

The final value of the event’s result property. For nullable result types, this can be null when no handler assigns a value.

Type Parameters

T

The event type to construct and publish.

TResult

The event result type.

UnregisterListeners(IEnumerable<IEventListener>)

Removes all subscribed methods belonging to a sequence of listener objects.

void UnregisterListeners(IEnumerable<IEventListener> listeners)

Parameters

listeners IEnumerable<IEventListener>

The listeners to unregister.

UnregisterListeners(params IEventListener[])

Removes all subscribed methods belonging to listener objects.

void UnregisterListeners(params IEventListener[] listeners)

Parameters

listeners IEventListener[]

The listeners to unregister.

WaitAsync(Func<IEvent, bool>, CancellationToken)

Waits until a subsequently published event satisfies a predicate.

ValueTask WaitAsync(Func<IEvent, bool> condition, CancellationToken cancellationToken = default)

Parameters

condition Func<IEvent, bool>

The predicate evaluated for each published event.

cancellationToken CancellationToken

A token used to cancel and remove the pending waiter.

Returns

ValueTask

A task that completes when condition returns true.

Exceptions

OperationCanceledException

cancellationToken is canceled before a matching event is published.