Skip to content

ObserverManager<TIdentity, TObserver> Methods

Maintains a collection of observers.

Clear

View source
public void ObserverManager<TIdentity, Clear()
Removes all observers.

GetEnumerator

View source
public IEnumerator<TObserver> ObserverManager<TIdentity, GetEnumerator()
Returns an enumerator that iterates through the collection.

Returns

A System.Collections.Generic.IEnumerator that can be used to iterate through the collection.

Notify(Func<TObserver, Task>, Func<TObserver, bool>)

View source
public Task ObserverManager<TIdentity, Notify(Func<TObserver, Task> notification, Func<TObserver, bool>? predicate = null)
Notifies all observers.

Parameters

notificationFunc<TObserver, Task>
The notification delegate to call on each observer.
predicateFunc<TObserver, bool>
The predicate used to select observers to notify.

Returns

A System.Threading.Tasks.Task representing the work performed.

Notify(Action<TObserver>, Func<TObserver, bool>)

View source
public void ObserverManager<TIdentity, Notify(Action<TObserver> notification, Func<TObserver, bool>? predicate = null)
Notifies all observers which match the provided predicate.

Parameters

notificationAction<TObserver>
The notification delegate to call on each observer.
predicateFunc<TObserver, bool>
The predicate used to select observers to notify.

Subscribe(TIdentity, TObserver)

View source
public void ObserverManager<TIdentity, Subscribe(TIdentity id, TObserver observer)
Ensures that the provided observer is subscribed, renewing its subscription.

Parameters

idTIdentity
The observer's identity.
observerTObserver
The observer.

Exceptions

System.Exception
A delegate callback throws an exception.

Unsubscribe(TIdentity)

View source
public void ObserverManager<TIdentity, Unsubscribe(TIdentity id)
Ensures that the provided id is unsubscribed.

Parameters

idTIdentity
The observer.