MPowerKit.Events 1.0.2

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package MPowerKit.Events --version 1.0.2
NuGet\Install-Package MPowerKit.Events -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MPowerKit.Events" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MPowerKit.Events --version 1.0.2
#r "nuget: MPowerKit.Events, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MPowerKit.Events as a Cake Addin
#addin nuget:?package=MPowerKit.Events&version=1.0.2

// Install MPowerKit.Events as a Cake Tool
#tool nuget:?package=MPowerKit.Events&version=1.0.2

MPowerKit.Events

This library gives you an ability to facilitate communication between loosely coupled components in an application.

NuGet

Inspired by Prism's EventAggregator.

Note: Main difference from Prism is that this library does not support different threads event publishing/handling. The event will be handled in that thread it was raised in. Also, code was refactored to use latest .net and c# features.

Usage

Register event aggregator in service collection:

serviceCollection.AddSingleton<IEventAggregator, EventAggregator>();

or use as singleton

EventAggregator.Current.GetEvent<>()

Create an event:

public class SomeEvent : PubSubEvent { }

or generic version

public class SomeGenericEvent : PubSubEvent<payload_type> { }

Subscribe to an event:

IEventAggregator _eventAggregator;

public void EventHandler() { }

_eventAggregator.GetEvent<SomeEvent>().Subscribe(EventHandler);

public void GenericEventHandler(payload_type payload) { }

_eventAggregator.GetEvent<SomeGenericEvent>().Subscribe(GenericEventHandler);

Publish an event:

IEventAggregator _eventAggregator;

_eventAggregator.GetEvent<SomeEvent>().Publish();

_eventAggregator.GetEvent<SomeGenericEvent>().Publish(payload);

Note: you may not unsubscribe from events, because it has weak reference, but better to do unsubscribe

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 448 12/29/2023
1.0.1 372 12/15/2023
1.0.0 493 12/13/2023