Class ObservableEventInvocable<T>
- Namespace
- WebDriverBiDi
- Assembly
- WebDriverBiDi.dll
Producer-side implementation of a subject in the Observer pattern for events, allowing a producer to notify observers.
public class ObservableEventInvocable<T> : ObservableEvent<T> where T : WebDriverBiDiEventArgs
Type Parameters
TThe type of event arguments containing information about the observable event.
- Inheritance
-
ObservableEventInvocable<T>
- Inherited Members
- Extension Methods
Constructors
ObservableEventInvocable(string)
Initializes a new instance of the ObservableEventInvocable<T> class.
public ObservableEventInvocable(string eventName)
Parameters
eventNamestringThe name of the event.
ObservableEventInvocable(string, uint)
Initializes a new instance of the ObservableEventInvocable<T> class.
public ObservableEventInvocable(string eventName, uint maxObserverCount)
Parameters
eventNamestringThe name of the event.
maxObserverCountuintThe maximum number of handlers that may observe this event.
Methods
InvokeNotifyObserversAsync(T)
Asynchronously notifies observers when this observable event occurs. Each observer is notified independently; an exception thrown by one observer does not prevent subsequent observers from being notified.
public Task InvokeNotifyObserversAsync(T notifyData)
Parameters
notifyDataTThe data of the event.
Returns
- Task
The task object representing the asynchronous operation.
Remarks
When an observer-error reporter is installed, as it is for every event the library creates, a failing observer reports its own failure through it, identifying itself, and this method does not throw for it. Without a reporter, a failure of a synchronously-run observer propagates to the caller: if exactly one observer throws, the original exception is rethrown; if multiple observers throw, an AggregateException containing all caught exceptions is thrown after all observers have been notified. A failure of an asynchronously-run observer never propagates to the caller.
Exceptions
- AggregateException
Thrown, when no observer-error reporter is installed, if multiple observer handlers throw an exception.
InvokeSetObserverErrorReporter(Func<EventObserverErrorInfo, Task>)
Sets the reporter through which observer failures are reported instead of propagating to the caller: a synchronously-run observer's failure as it happens, and an asynchronously-run observer's failure after its handler has returned.
public void InvokeSetObserverErrorReporter(Func<EventObserverErrorInfo, Task> reporter)
Parameters
reporterFunc<EventObserverErrorInfo, Task>The reporter callback.