Skip to content

Subscribe and Publish

Damian edited this page Jan 24, 2026 · 1 revision

Basic Subscribe and Publish

At the heart of Lite.EventIpc is the simple Subscribe<T> and Publish(T) used for subscribing to published events.

using Lite.EventIpc;

public class UserCreatedEvent
{
  public string UserName { get; set; }
}

static void Main()
{
  var eventAggregator = new EventAggregator();

  // Subscribe
  eventAggregator.Subscribe<UserCreatedEvent>(e =>
    Console.WriteLine($"User created: {e.Username}"));

  // Publish
  eventAggregator.Publish(new UserCreatedEvent { Username = "Damian" })
}

Clone this wiki locally