Search Results for

    Show / Hide Table of Contents

    Class EventExtensions

    Inheritance
    object
    EventExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastEndpoints
    Assembly: FastEndpoints.dll
    Syntax
    public static class EventExtensions

    Methods

    Broadcast<TEvent>(TEvent)

    broadcast/publish an event to all remote subscribers. this method should only be called when the server is running in EventPublisher hub mode

    Declaration
    public static void Broadcast<TEvent>(this TEvent @event) where TEvent : class, IEvent
    Parameters
    Type Name Description
    TEvent event
    Type Parameters
    Name Description
    TEvent

    the type of the event being broadcast

    PublishAsync(IEvent, Mode, CancellationToken)

    publish the event to all subscribers registered to handle this type of event.

    Declaration
    public static Task PublishAsync(this IEvent eventModel, Mode waitMode = Mode.WaitForAll, CancellationToken cancellation = default)
    Parameters
    Type Name Description
    IEvent eventModel

    the notification event model/dto to publish

    Mode waitMode

    specify whether to wait for none, any or all of the subscribers to complete their work

    CancellationToken cancellation

    an optional cancellation token

    Returns
    Type Description
    Task

    a Task that matches the wait mode specified. WaitForNone returns an already completed Task (fire and forget). WaitForAny returns a Task that will complete when any of the subscribers complete their work. WaitForAll return a Task that will complete only when all of the subscribers complete their work.

    PublishAsync<TEvent>(TEvent, Mode, CancellationToken)

    publish the event to all subscribers registered to handle this type of event.

    Declaration
    public static Task PublishAsync<TEvent>(this TEvent eventModel, Mode waitMode = Mode.WaitForAll, CancellationToken cancellation = default) where TEvent : IEvent
    Parameters
    Type Name Description
    TEvent eventModel

    the notification event model/dto to publish

    Mode waitMode

    specify whether to wait for none, any or all of the subscribers to complete their work

    CancellationToken cancellation

    an optional cancellation token

    Returns
    Type Description
    Task

    a Task that matches the wait mode specified. WaitForNone returns an already completed Task (fire and forget). WaitForAny returns a Task that will complete when any of the subscribers complete their work. WaitForAll return a Task that will complete only when all the subscribers complete their work.

    Type Parameters
    Name Description
    TEvent

    the type of the event model

    PublishFilteredAsync<TEvent>(TEvent, Func<Type, bool>, Mode, CancellationToken)

    publish the event to a subset of the subscribers registered to handle this type of event.

    Declaration
    public static Task PublishFilteredAsync<TEvent>(this TEvent eventModel, Func<Type, bool> handlerFilter, Mode waitMode = Mode.WaitForAll, CancellationToken cancellation = default) where TEvent : IEvent
    Parameters
    Type Name Description
    TEvent eventModel

    the notification event model/dto to publish

    Func<Type, bool> handlerFilter

    a predicate for selecting which of the registered event handlers should be executed. if the predicate returns false for a particular event handler, that handler will not be executed during the invocation.

    Mode waitMode

    specify whether to wait for none, any or all of the subscribers to complete their work

    CancellationToken cancellation

    an optional cancellation token

    Returns
    Type Description
    Task

    a Task that matches the wait mode specified. WaitForNone returns an already completed Task (fire and forget). WaitForAny returns a Task that will complete when any of the subscribers complete their work. WaitForAll return a Task that will complete only when all the subscribers complete their work.

    Type Parameters
    Name Description
    TEvent

    the type of the event model

    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX