Add Observable and SynchronizedObserver utilities#46
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/fbb0abef-7fbe-4dcc-b6db-72ec79d85079 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/25a88c8e-8da0-4f57-b4c2-333e38948ed3 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Ports lightweight IObservable<T>/IObserver<T> utilities into PowerKit (aligned with the project’s existing “small internal building blocks” approach) and adds tests to validate subscription behavior and synchronized delivery across threads.
Changes:
- Added
Observable<T>+Observablefactory helpers to create observables from a subscribe delegate. - Added
SynchronizedObserver<T>to serialize observer callbacks vialock, andObservable.CreateSynchronized<T>to apply it automatically. - Added unit tests covering basic observable behavior and a multi-threaded delivery scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| PowerKit/SynchronizedObserver.cs | Adds an IObserver<T> decorator that serializes OnNext/OnError/OnCompleted calls. |
| PowerKit/Observable.cs | Adds a minimal IObservable<T> implementation + factory helpers including synchronized creation. |
| PowerKit.Tests/ObservableTests.cs | Adds coverage for Observable.Create, disposal propagation, and synchronized/thread-safe delivery. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e class Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/961a742f-c577-4b9c-ac9e-ccf561b3abe1 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/f086db47-cb63-4e4d-b9ff-a1b63000e787 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## prime #46 +/- ##
==========================================
- Coverage 94.36% 94.35% -0.02%
==========================================
Files 82 87 +5
Lines 1740 1878 +138
Branches 141 152 +11
==========================================
+ Hits 1642 1772 +130
- Misses 72 77 +5
- Partials 26 29 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/a292f88b-67bc-49ee-bc23-32d920986e9d Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Ports
ObservableandSynchronizedObserverutility types from CliWrap into PowerKit.New types
Observable<T>—IObservable<T>implementation backed by a subscribe delegate.Observable(static) — factory methods:Create<T>— wraps a subscribe delegate into an observable.CreateSynchronized<T>— same, but wraps the observer inSynchronizedObserver<T>before invoking the delegate, ensuring thread-safe delivery.SynchronizedObserver<T>—IObserver<T>decorator that serializesOnNext/OnError/OnCompletedcalls vialock.Both files are guarded with
#if NET40_OR_GREATER || NETSTANDARD || NETsinceIObservable<T>/IObserver<T>don't exist in .NET 3.5.Usage