Skip to content

fix!: make a lone SubscribeSafe delegate the onNext handler - #231

Merged
glennawatson merged 1 commit into
mainfrom
fix/subscribesafe-lone-delegate-is-onnext
Oct 3, 2026
Merged

glennawatson merged 1 commit into
mainfrom
fix/subscribesafe-lone-delegate-is-onnext

Conversation

@glennawatson

@glennawatson glennawatson commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A lone delegate passed to SubscribeSafe is now the onNext handler, as in System.Reactive. Error-only subscriptions move to a new name.

  • Adds 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.
  • Adds SubscribeSafeErrors(onError) and SubscribeSafeErrors(onError, onCompleted), which keep the old error-only behaviour.
  • Removes the error-only SubscribeSafe(onError) and SubscribeSafe(onError, onCompleted) overloads.

Why

SubscribeSafe had error-only overloads but no onNext-only overload. So source.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. Write SubscribeSafeErrors(onError) instead.
  • SubscribeSafe(onError, onCompleted) is removed. Write SubscribeSafeErrors(onError, onCompleted) instead.
  • A lone delegate passed to SubscribeSafe now 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 SubscribeSafeErrors errors and completion for every source variant.

Notes for the reviewer

Start with src/Primitives.Shared/SignalOperatorParityMixins.RxNames.SubscribeSafe.cs and the extension block in SignalOperatorParityMixins.RxNames.cs. The OverloadResolutionPriority values 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

  • I have read the Contribute guide
  • The PR title follows Conventional Commits
  • Tests cover this change, or the summary says why they do not
  • New or changed public API has XML documentation

- 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

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.78%. Comparing base (fc7e0fa) to head (6c0bb8b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Oct 3, 2026

Copy link
Copy Markdown

@glennawatson
glennawatson merged commit 56523df into main Oct 3, 2026
16 checks passed
@glennawatson
glennawatson deleted the fix/subscribesafe-lone-delegate-is-onnext branch October 3, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant