JKang.Events.InMemory 0.1.0

Package Description

Install-Package JKang.Events.InMemory -Version 0.1.0
dotnet add package JKang.Events.InMemory --version 0.1.0
<PackageReference Include="JKang.Events.InMemory" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JKang.Events.InMemory --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

JKang.Events

A .NET Core ultra lightweight in-memory event bus implementation.

Sample:

  1. Create an event implementing IEvent interface
    public class MessageSent : IEvent
    {
        public static MessageSent Create(string message)
        {
            return new MessageSent(Guid.NewGuid(), message);
        }

        private MessageSent(Guid eventId, string message)
        {
            EventId = eventId;
            Message = message;
        }

        public Guid EventId { get; }

        public string Message { get; }
  1. Implement an event handler and register it IoC
    public class MessageSentEventHandler : IEventHandler<MessageSent>
    {
        public Task HandleEventAsync(MessageSent @event)
        {
            // consume the event here
            return Task.CompletedTask;
        }
    }
    // Startup.cs
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddInMemoryEvents()
            .AddScoped<IEventHandler<MessageSent>, MessageSentEventHandler>()
            ;
    }
  1. Publish the event
    var @event = MessageSent.Create("Hello world!");
    await _eventPublisher.PublishEventAsync(@event);

Any contributions or comments are welcome!

JKang.Events

A .NET Core ultra lightweight in-memory event bus implementation.

Sample:

  1. Create an event implementing IEvent interface
    public class MessageSent : IEvent
    {
        public static MessageSent Create(string message)
        {
            return new MessageSent(Guid.NewGuid(), message);
        }

        private MessageSent(Guid eventId, string message)
        {
            EventId = eventId;
            Message = message;
        }

        public Guid EventId { get; }

        public string Message { get; }
  1. Implement an event handler and register it IoC
    public class MessageSentEventHandler : IEventHandler<MessageSent>
    {
        public Task HandleEventAsync(MessageSent @event)
        {
            // consume the event here
            return Task.CompletedTask;
        }
    }
    // Startup.cs
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddInMemoryEvents()
            .AddScoped<IEventHandler<MessageSent>, MessageSentEventHandler>()
            ;
    }
  1. Publish the event
    var @event = MessageSent.Create("Hello world!");
    await _eventPublisher.PublishEventAsync(@event);

Any contributions or comments are welcome!

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.0 309 2/19/2018