Skip to content

fix(observables): deliver property changes on the raising thread - #105

Merged
glennawatson merged 1 commit into
mainfrom
fix/observation-raising-thread
Sep 15, 2026
Merged

glennawatson merged 1 commit into
mainfrom
fix/observation-raising-thread

Conversation

@glennawatson

@glennawatson glennawatson commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix.

What is the new behavior?

WhenChanged, WhenAnyValue and WhenAny deliver each property change on the thread that set the property.

  • Only the binding operators (Bind, BindTwoWay, OneWayBind, BindOneWay, BindTo, BindCommand) move work onto a thread, because they connect a view to a view model.
  • The observation operators are for general use, so the caller supplies the threading arrangement.
  • A setter on one thread waits for at most the delivery already running on another thread.
  • A change raised from inside a running delivery is delivered after the subscriber returns.

What is the current behavior?

When two threads set the same property at once, one thread delivers the other thread's changes.

  • An observation subscriber can run on a thread other than the one that set the property.
  • A thread already delivering a change is held for as long as the other thread keeps setting the property.

What might this PR break?

None

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

This fixes an unintended threading change that shipped in 7.0.0 and 7.0.1 through #100.

- A change raised on another thread waits for the running emit and is delivered on the thread that raised it.
- A change raised from inside a running emit is delivered after the observer returns.
- Only the binding operators move work onto the view's thread; observation operators leave threading to the caller.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.73%. Comparing base (e200cb3) to head (04c9743).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #105   +/-   ##
=======================================
  Coverage   99.73%   99.73%           
=======================================
  Files         289      289           
  Lines       11533    11537    +4     
  Branches     1259     1259           
=======================================
+ Hits        11502    11506    +4     
  Misses         18       18           
  Partials       13       13           

☔ 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.

@glennawatson
glennawatson merged commit 3f924ce into main Sep 15, 2026
18 checks passed
@glennawatson
glennawatson deleted the fix/observation-raising-thread branch September 15, 2026 01:50
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