implementing-pubsub-pattern

Solid

Implements Pub-Sub patterns using System.Reactive and Channels for event-based communication in .NET. Use when building reactive applications or decoupled event-driven architectures.

Web & Frontend 40 stars 6 forks Updated 6 days ago MIT

Install

View on GitHub

Quality Score: 78/100

Stars 20%
54
Recency 20%
100
Frontmatter 20%
40
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# .NET Pub-Sub Pattern A guide for Pub-Sub patterns for event-based asynchronous communication. **Quick Reference:** See [QUICKREF.md](QUICKREF.md) for essential patterns at a glance. ## 1. Core APIs | API | Purpose | NuGet | |-----|---------|-------| | `System.Reactive` (Rx.NET) | Reactive event streams | System.Reactive | | `System.Threading.Channels` | Async Producer-Consumer | BCL | | `IObservable<T>` | Observable sequence | BCL | --- ## 2. System.Threading.Channels ### 2.1 Basic Usage ```csharp using System.Threading.Channels; public sealed class MessageProcessor { private readonly Channel<Message> _channel = Channel.CreateUnbounded<Message>(); // Producer - Send message public async Task SendAsync(Message message) { await _channel.Writer.WriteAsync(message); } // Consumer - Process message public async Task ProcessAsync(CancellationToken ct) { await foreach (var message in _channel.Reader.ReadAllAsync(ct)) { await HandleMessage(message); } } // Channel completion signal public void Complete() => _channel.Writer.Complete(); } ``` ### 2.2 Bounded Channel (Backpressure Control) ```csharp // Backpressure control with buffer size limit var options = new BoundedChannelOptions(capacity: 100) { FullMode = BoundedChannelFullMode.Wait, // Wait when full SingleReader = true, SingleWriter = false }; var channel = Channel.CreateBounded<Message>(options); // Wri...

Details

Author
christian289
Repository
christian289/dotnet-with-claudecode
Created
7 months ago
Last Updated
6 days ago
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category