Broadcaster.PubSub.Framework 1.0.1

Used to communicate events from object to subscribers instead of the standard .NET event system. Provides IDisposable tokens for unsubscribing and the ability to provide enums or objects as events/messages with or without payloads.

All handlers are awaited (and awaitable), unsubscription is dead simple, and the implemenations are lightweight.  Strongly typed where we can be, of course.

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

Broadcaster

A lightweight, simple, and efficient system to replace clunky, memory-leak inducing, typical event subscriptions in .NET Standard.

Typcial event subscriptions like this:

SomeObservableCollection.CollectionChanged += (s,e) => Ahandler();

...will always result in a memory leak. This forces the conscientious developer to create a method like this:

SomeObservableCollection.CollectionChanged += OnCollectionChanged;
...
private void OnCollectionChanged(object sender, CollectionChangedEventArgs a) 
{
... do some stuff ...
}

And then when the subscription is no longer desired:

SomeObservableCollection.CollectionChanged -= OnCollectionChanged;

If used correctly, this will never create a memory leak (emphasis on 'if'). This mechanism is clunky, wordy, and obtuse.

UI still and probably will always require true events (marked with the event keyword) to latch onto, but for the rest of the business code,
I think we'd all prefer something a bit...cleaner and easier to use. See the wiki for an example.

Broadcaster provides a frameworkd for easily listening for, handling, and unsubscribing from events that allows the use of lambdas (!!).
It's a thing of beauty to use in a large application (which I have) and once this easy to use system is understood, it is simple to
unsubscribe to any and all events. If you are familiar with the Reactive framework, then this will be right up your alley.

The syntax is similar to subscribing to a Reactive event, but less wordy and obtuse, but it does follow the same disposable token
methodology (because that is far and above the best way to subscribe/unsubscribe from events).

If you are already using the Reactive framework, just use their event pattern. This is a lightweight framework that just focuses on simple event subscription/unsubscription and nothing else.

If you're using the EventAggregator or some other PubSub mechanism, this may be a better alternative b/c it is strongly typed when it can be, but allows loose typing with enums, too. And it awaits all handlers! Can be used in a global scope, or a local scope.

Show me some :heart: and star this repo to support my project

Created & Maintained By

Brent Bulla (@outbred)
(Insta)

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of <img src="https://vignette.wikia.nocookie.net/logopedia/images/a/ad/Dr._Pepper_1958.jpg/revision/latest?cb=20100924201743" height="25em" /> - PayPal

Broadcaster

A lightweight, simple, and efficient system to replace clunky, memory-leak inducing, typical event subscriptions in .NET Standard.

Typcial event subscriptions like this:

SomeObservableCollection.CollectionChanged += (s,e) => Ahandler();

...will always result in a memory leak. This forces the conscientious developer to create a method like this:

SomeObservableCollection.CollectionChanged += OnCollectionChanged;
...
private void OnCollectionChanged(object sender, CollectionChangedEventArgs a) 
{
... do some stuff ...
}

And then when the subscription is no longer desired:

SomeObservableCollection.CollectionChanged -= OnCollectionChanged;

If used correctly, this will never create a memory leak (emphasis on 'if'). This mechanism is clunky, wordy, and obtuse.

UI still and probably will always require true events (marked with the event keyword) to latch onto, but for the rest of the business code,
I think we'd all prefer something a bit...cleaner and easier to use. See the wiki for an example.

Broadcaster provides a frameworkd for easily listening for, handling, and unsubscribing from events that allows the use of lambdas (!!).
It's a thing of beauty to use in a large application (which I have) and once this easy to use system is understood, it is simple to
unsubscribe to any and all events. If you are familiar with the Reactive framework, then this will be right up your alley.

The syntax is similar to subscribing to a Reactive event, but less wordy and obtuse, but it does follow the same disposable token
methodology (because that is far and above the best way to subscribe/unsubscribe from events).

If you are already using the Reactive framework, just use their event pattern. This is a lightweight framework that just focuses on simple event subscription/unsubscription and nothing else.

If you're using the EventAggregator or some other PubSub mechanism, this may be a better alternative b/c it is strongly typed when it can be, but allows loose typing with enums, too. And it awaits all handlers! Can be used in a global scope, or a local scope.

Show me some :heart: and star this repo to support my project

Created & Maintained By

Brent Bulla (@outbred)
(Insta)

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of <img src="https://vignette.wikia.nocookie.net/logopedia/images/a/ad/Dr._Pepper_1958.jpg/revision/latest?cb=20100924201743" height="25em" /> - PayPal

Release Notes

Updated icon

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 196 10/8/2018
1.0.0 158 10/7/2018