EventAggregatorLite 1.0.1

dotnet add package EventAggregatorLite --version 1.0.1
NuGet\Install-Package EventAggregatorLite -Version 1.0.1
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="EventAggregatorLite" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EventAggregatorLite --version 1.0.1
#r "nuget: EventAggregatorLite, 1.0.1"
#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 EventAggregatorLite as a Cake Addin
#addin nuget:?package=EventAggregatorLite&version=1.0.1

// Install EventAggregatorLite as a Cake Tool
#tool nuget:?package=EventAggregatorLite&version=1.0.1

EvantAggregatorLite short, step by step tutorial:

  1. Create Your event class that implement IBaseEvent interface (You can store all event classes in separate folder MyEvents for example)
using EventAggregator.Interfaces;

public class AddWindowsEvent : IBaseEvent
{
	public string EventDesctiption => "This is AddWindowsEvent desc";
	
	//You can add any code to event class, properties, for instance 
	public string Name{get; set;}
	public List<Windows> WindowsList{get;set;}

}
  1. In a class that wants to receive notifications, create a method that takes your event as a parameter (this is a callback method):
public void AddItem(AddWindowsEvent receivedEvent)
{
	//place the code to handle the event here
	System.Diagnostics.Debug.Print($"List of Windows contains {receivedEvent.WindowsList.Count} items");
}
  1. Create EventAggregatorLite object and subscribe for Your event(s):
using EventAggregator.Core;

public class VIPClass
{
	private EventAggregatorLite eal;

	public VIPClass
	{
	//create new instance EventAggregatorLite
	eal=new EventAggregatorLite(); 
	
	//set AddItem method to handle AddWindowsEvent events
	eal.Subscribe<AddWindowsEvent>(AddItem); 
	}


public void AddItem(AddWindowsEvent receivedEvent)
{
	//place the code to handle the event here
	System.Diagnostics.Debug.Print($"List of Windows contains {WindowsList.Count} items");
}

}
  1. In "sender" class create and configure event instance and publish it:
//create and configure event
IBaseEvent eventToPublish = new AddWindowsEvent();
eventToPublish.WindowsList=new List<Window>();
eventToPublish.WindowsList.Add(new Window());

//publish to all AddWindowsEvent event sybscribers
localEal.Publish(eventToPublish);
  1. If You want to unsubscribe just use:
eal.Unsubscribe<AddWindowsEvent>(AddItem);

It's important:

  • You must use the same EventAggregatorLite instance in all components that communicate with each other via events (in example above eal and localEal objects refer to the same instance of EventAggregatorLite).
  • You can pass EventAggregatorLite instance as constructor parameter, or better, use Dependency Injection container and configure it to resolve EventAggregatorLite as singleton.
  • If You want to avoid memory leaks always unsubscribe when removing / dropping objects that have subscribed to some events. This is a very simple EventAggregator that doesn't use weak object references.
  • If you need a more professional event aggregator, use, for example, the EventAggregator from the Prism package (from Brian Lagunas and Dan Siegel).
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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.1 353 11/3/2021