fix!: make a lone SubscribeSafe delegate the onNext handler - #231
Merged
Merged
Conversation
- Add SubscribeSafe(onNext). A lone delegate is the onNext handler, as in System.Reactive. - Remove the error-only SubscribeSafe(onError) and SubscribeSafe(onError, onCompleted) overloads. They captured a lone lambda as the error handler, so values were silently dropped. - Add SubscribeSafeErrors(onError) and SubscribeSafeErrors(onError, onCompleted) for error-only subscriptions. - Move in-repo callers and the README to SubscribeSafeErrors. - Update the ReactiveUI.Primitives and ReactiveUI.Primitives.Reactive public API baselines. BREAKING CHANGE: SubscribeSafe(onError) and SubscribeSafe(onError, onCompleted) are removed. Use SubscribeSafeErrors. A lone delegate passed to SubscribeSafe is now the onNext handler.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #231 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 785 785
Lines 24923 24927 +4
Branches 2957 2957
=======================================
+ Hits 24869 24873 +4
Misses 54 54 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
A lone delegate passed to
SubscribeSafeis now the onNext handler, as in System.Reactive. Error-only subscriptions move to a new name.SubscribeSafe(Action<T> onNext)for class, nullable-struct and value-type sources. With no error handler, a source error is rethrown with its original stack.SubscribeSafeErrors(onError)andSubscribeSafeErrors(onError, onCompleted), which keep the old error-only behaviour.SubscribeSafe(onError)andSubscribeSafe(onError, onCompleted)overloads.Why
SubscribeSafehad error-only overloads but no onNext-only overload. Sosource.SubscribeSafe(x => Use(x))compiled and bound the lambda as the error handler. Every value, including the initial one, was silently dropped.Breaking changes
SubscribeSafe(onError)is removed. WriteSubscribeSafeErrors(onError)instead.SubscribeSafe(onError, onCompleted)is removed. WriteSubscribeSafeErrors(onError, onCompleted)instead.SubscribeSafenow binds as onNext. Code that meant an error handler no longer compiles, or now receives values.How this was verified
New tests cover method group, lambda and discard-lambda onNext, the error rethrow, and
SubscribeSafeErrorserrors and completion for every source variant.Notes for the reviewer
Start with
src/Primitives.Shared/SignalOperatorParityMixins.RxNames.SubscribeSafe.csand the extension block inSignalOperatorParityMixins.RxNames.cs. TheOverloadResolutionPriorityvalues decide which overload a lone lambda picks, so they deserve the closest look. The test caller updates, the README and the public API baselines are mechanical.Checklist