LightMessageBus 1.0.2

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

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

What is LightMessageBus?

A simple, light-weight application level event aggregator which facilitates the exchange of messages between objects without direct references.

Use-cases and examples?

A soundComponent needs to be notified whenever a user clicks on any button.

MessageBus.Default.FromAny().Where<ButtonClickMessage>().Notify(soundComponent)

A taxCalculator needs to be notified whenever shopping cart is changed.

MessageBus.Default.From(shoppingCart).Notify(taxCalculator);

How is this achieved?

LightMessageBus uses a simple publisher/subscriber pattern.

  • Subscribers use the MessageBus to subscribe to messages they wish to be notified about. They may wish to filter messages by the source, type of message or some other predicate.
  • Publishers use the MessageBus to publish messages to the potential subscribers
  • Neither subscribers nor publishers have any references to each other. They simply use a common communication channel - the MessageBus

How does that help?

The pub/sub pattern enables you to promote decoupled architecture in your application. Since there is no need for various objects (views, models, controllers, ...) to know of each other existence - you are free to develop them independently in isolation. Such architecture enables testing, refactoring and limits the propagation of changes through the system.

Why not use delegates/events?

Using delegates and/or events requires a reference between the publisher and the subscriber (subscribers reference publishers or vice-versa). Any change to the referenced class will affect the other. Such change may even propagate through the system resulting in significant changes due to a small cause.

How is it used?

LightMessageBus uses LINQ-like, fluent syntax for maximum readability and flexibility. The basic building blocks of a LightMessageBus registration expression are: From, Where and Notify.

First we define the publishers:

  • From - specifies publisher(s) of interest to subscriber.
  • FromAny - specifies any publisher.

Next we optionally define the messages:

  • Where - specifies the types of messages of interest to subscriber.

Lastly we define the subscriber:

  • Notify - specifies the subscriber.
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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.1

    • 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 767 9/10/2021
1.0.1 4,495 5/25/2016
1.0.0 1,422 9/19/2014

UPGRADE - Ported main project to netstandard 2.1 and test project to net5.