Skip to content

vincentnacar02/AppEventService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppEventService

Simple Blazor server app event service that handles real-time events for multiple users

Build and tests

design

Basic usage

// register service
Services.AddAppEventService<TodoUpdatedEvent>();

// inject to component
@inject IAppEventService<TodoUpdatedEvent> _appEventService;

// create dispatcher
var todo = ...;
_dispatcher = _appEventService.GetOrCreateDispatcher(todo.Id);

// create action
public void OnTodoUpdated(TodoUpdatedEvent ev)
{
  InvokeAsync(() =>
  {
      // do something with event
      ...
      StateHasChanged();
  });
}

...

_dispatcher.AddAction(OnTodoUpdated);

...

// publish event
await _dispatcher.PublishEventAsync(new TodoUpdatedEvent());

// cleanup
_dispatcher.RemoveAction(OnTodoUpdated);
_appEventService.DestroyDispatcher(_dispatcher.Key);

Check the Samples folder for more info

Installation

NuGet\Install-Package AppEventService -Version 1.0.0.1

About

Simple Blazor server app event service that handles real-time events for multiple users

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages