Skip to content
FluentEvents is an event aggregation framework for implementing domain events and integration events in DDD applications
C#
Branch: master
Clone or download

README.md

FluentEvents logo

Build status NuGet

What is FluentEvents?

FluentEvents is an event aggregation framework for implementing domain events and integration events in DDD applications.

FluentEvents can:

  • Manage domain events
  • Manage integration events
  • Manage Two-phase domain events (A better domain events pattern)
  • Generalize events using projections
  • Invoke SignalR methods when events are raised

How it works:

public class MyEventsContext : EventsContext
{
    protected override void OnBuildingSubscriptions(SubscriptionsBuilder subscriptionsBuilder)
    {
        subscriptionsBuilder
            .ServiceHandler<NotificationsService, User, FriendRequestAcceptedEventArgs>()
            .HasGlobalSubscription((user, h) => user.FriendRequestAccepted += h);
    }

    protected override void OnBuildingPipelines(PipelinesBuilder pipelinesBuilder)
    {
        pipelinesBuilder
            .Event<User, FriendRequestAcceptedEventArgs>((user, h) => user.FriendRequestAccepted += h)
            .IsWatched()
            .ThenIsPublishedToGlobalSubscriptions();
    }
}
public class NotificationsService : IEventHandler<User, FriendRequestAcceptedEventArgs>
{
    private readonly IMailService _mailService;

    public NotificationsService(IMailService mailService)
    {
        _mailService = mailService;
    }

    public async Task HandleEventAsync(User user, FriendRequestAcceptedEventArgs e)
    {
        await _mailService.SendFriendRequestAcceptedEmail(e.RequestSender.EmailAddress, user.Id, user.Name);
    }
}
You can’t perform that action at this time.