Fix for 4280 interaction async handler scheduling#4351
Merged
ChrisPulman merged 2 commits intomainfrom May 4, 2026
Merged
Conversation
glennawatson
approved these changes
May 4, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4351 +/- ##
==========================================
+ Coverage 89.85% 89.86% +0.01%
==========================================
Files 253 253
Lines 9638 9652 +14
Branches 1475 1476 +1
==========================================
+ Hits 8660 8674 +14
Misses 734 734
Partials 244 244 ☔ View full report in Codecov by Sentry. 🚀 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.
What kind of change does this PR introduce?
Fix
What is the current behavior?
Closes #4280
What is the new behavior?
This pull request refactors the
Interactionhandler registration and execution logic inReactiveUIto improve consistency, reliability, and testability, especially around asynchronous handler scenarios. It introduces a unified handler registration core, ensures asynchronous handlers yield to the current context, and updates tests to use modern async/await patterns. Several new tests are also added to verify scheduler release behavior for both task-based and observable handlers.Core handler registration and async context improvements:
RegisterHandlerCoremethod to centralize handler registration and disposal logic, replacing duplicated code inRegisterHandleroverloads. [1] [2]YieldToCurrentContextmethod to ensure asynchronous handlers (bothTaskandIObservable-based) yield execution before invoking user code, preventing scheduler trampoline issues and improving nested interaction support. [1] [2]Test modernization and reliability:
InteractionsTest.csto useasync/awaitandToTask()instead of synchronous blocking (Wait()/FirstAsync().Wait()), improving test reliability and better reflecting real-world async usage. [1] [2] [3] [4] [5] [6]InteractionsTestclass with[NotInParallel]to ensure tests are not run in parallel, avoiding flakiness due to shared state.Expanded test coverage for async handler behavior:
Task-based andIObservable-based handlers release the current scheduler before executing user code, ensuring nested interactions are not blocked and behave as expected.Test improvements for handler precedence and subscription timing:
TaskCompletionSourcefor precise subscription tracking. [1] [2]These changes collectively make handler registration more robust, improve async interaction patterns, and ensure that both the implementation and test suite are future-proof and reliable.
What might this PR break?
Checklist
mainbranchAdditional information