Skip to content

CodeBlueDev/CodeBlueDev.EventAggregator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CodeBlueDev.EventAggregator

A publish/subscribe aggregator to be used to decouple objects.

Subscribe

public class PingHandler
{
    public PingHandler()
    {
        this.Subscribe<Ping>(async pingEvent => Task.Run(() => this.WritePing()));
    }
    
    //...
}

Publish

public class Pong 
{
    // ...
    public void SomeMethod()
    {
        this.Publish(new Ping().AsTask());
    }
    // ...
}

Unsubscribe

public class PingHandler
{
    // ...
    public void Dispose()
    {
        this.Unsubscribe<Ping>();
    }
    // ...
}

Note

This is but one way to use the library in a somewhat object-oriented manner. See the Console.Test project for another example.

Warning

If this is being used in a WinForms project, check for InvokeRequired before writing the handler code or you'll have a bad time. Exceptions will be thrown and you may not understand why.

About

A publish/subscribe aggregator for when events occur.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages