Table of Contents

Interface IEventAggregator

Namespace
BSGameLib.Game.Events
Assembly
BSGameLib.Game.dll

Delivers messages from publishers to the handlers subscribed to their type, so the two do not need to know each other.

public interface IEventAggregator

Properties

Subscriptions

The active subscriptions, as tokens.

IReadOnlyCollection<IEventSubscriptionToken> Subscriptions { get; }

Property Value

IReadOnlyCollection<IEventSubscriptionToken>

Methods

Clear()

Removes every subscription.

void Clear()

Publish<T>(T)

Delivers message to every handler subscribed to T.

void Publish<T>(T message) where T : IEvent

Parameters

message T

Type Parameters

T

Subscribe<T>(Action<T>)

Subscribes a handler to messages of type T. Disposing the returned token unsubscribes it.

IEventSubscriptionToken Subscribe<T>(Action<T> action) where T : IEvent

Parameters

action Action<T>

Returns

IEventSubscriptionToken

Type Parameters

T

Subscribe<T>(Action<T>, IEventSubscriptionToken)

Subscribes a handler under a token the caller made. Unsubscribe with that token to stop it.

IEventSubscriptionToken Subscribe<T>(Action<T> action, IEventSubscriptionToken subscriptionToken) where T : IEvent

Parameters

action Action<T>
subscriptionToken IEventSubscriptionToken

Returns

IEventSubscriptionToken

Type Parameters

T

Unsubscribe(IEventSubscriptionToken)

Removes the subscription with this token.

void Unsubscribe(IEventSubscriptionToken subscriptionToken)

Parameters

subscriptionToken IEventSubscriptionToken