https://github.com/olivegamestudio/eventweave
Lightweight event aggregation with zero dependencies. Pub/sub messaging for decoupled service-to-service communication.
https://github.com/olivegamestudio/eventweave
communitytoolkit-mvvm csharp decoupled event event-aggregator events godot pubsub unity
Last synced: about 2 months ago
JSON representation
Lightweight event aggregation with zero dependencies. Pub/sub messaging for decoupled service-to-service communication.
- Host: GitHub
- URL: https://github.com/olivegamestudio/eventweave
- Owner: olivegamestudio
- Created: 2026-04-21T16:56:08.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-21T18:02:22.000Z (about 2 months ago)
- Last Synced: 2026-04-21T19:43:05.747Z (about 2 months ago)
- Topics: communitytoolkit-mvvm, csharp, decoupled, event, event-aggregator, events, godot, pubsub, unity
- Language: C#
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# EventWeave
Lightweight event aggregation for .NET. Zero dependencies. Decoupled pub/sub messaging between services.
## Why
When services need to communicate without knowing about each other, you need a message bus. EventWeave provides a minimal `IEventAggregator` that handles subscription, publication, and cleanup — with weak references to prevent memory leaks.
No frameworks. No reflection. No magic. Just pub/sub.
## Install
```
dotnet add package EventWeave
dotnet add package EventWeave.CommunityToolkit
```
## Install into Unity
In `Package Manager` add the following git url:
```
https://github.com/olivegamestudio/EventWeave.git?path=/upm
```
## Quick start
Define a message as a record:
```csharp
public sealed record OrderPlacedMessage(int OrderId, decimal Total);
```
Subscribe:
```csharp
public sealed class NotificationService
{
public NotificationService(IEventAggregator events)
{
events.Subscribe(this, OnOrderPlaced);
}
void OnOrderPlaced(OrderPlacedMessage message)
{
// send notification
}
}
```
Publish:
```csharp
public sealed class OrderService
{
readonly IEventAggregator _events;
public OrderService(IEventAggregator events)
{
_events = events;
}
public void PlaceOrder(int orderId, decimal total)
{
// process order
_events.Publish(new OrderPlacedMessage(orderId, total));
}
}
```
Unsubscribe when done:
```csharp
events.Unsubscribe(this);
```
## Setup
### Standalone (no DI)
```csharp
IEventAggregator events = new EventAggregator();
```
### Microsoft DI
```csharp
services.AddSingleton();
```
### CommunityToolkit.Mvvm adapter
If you already use `IMessenger` in your presentation layer and want EventWeave in your application layer:
```
dotnet add package EventWeave.CommunityToolkit
```
```csharp
services.AddSingleton();
services.AddSingleton();
```
## Diagnostics
`Publish` automatically captures caller information for debugging:
```csharp
public interface IEventAggregator
{
void Publish(
TMessage message,
[CallerMemberName] string? caller = null,
[CallerFilePath] string? file = null)
where TMessage : class;
}
```
## Packages
| Package | Purpose |
|---|---|
| `EventWeave` | Core library. `IEventAggregator`, `EventAggregator`. Zero dependencies, netstandard2.0. |
| `EventWeave.CommunityToolkit` | Adapter `MessengerEventAggregator` wrapping `IMessenger` from CommunityToolkit.Mvvm. |
## Design principles
- **Zero dependencies** in the core package. Runs on .NET Framework 4.6.2, .NET 10, Unity, MonoGame — anywhere netstandard2.0 works.
- **Thread safe.** Subscriptions and publications are safe to call from any thread.
- **No reflection.** All wiring is explicit or source-generated.
- **Messages are records.** Immutable, equatable, pattern-matchable.
## License
MIT