Skip to content

fix(mobx): include observableKind and debugObjectName in observe events of boxed values - #4761

Merged
kubk merged 1 commit into
mobxjs:mainfrom
Enesuygurs:fix/observable-value-change-kind
Nov 1, 2026
Merged

kubk merged 1 commit into
mobxjs:mainfrom
Enesuygurs:fix/observable-value-change-kind

Conversation

@Enesuygurs

Copy link
Copy Markdown
Contributor

observe on a boxed observable, an observable object property or an observable map entry delivers update events without observableKind and debugObjectName, although IValueDidChange declares both as required and the docs list them for every observe event. The fireImmediately event in observe already includes them, so a listener sees them on the first call and undefined on every later one:

const box = observable.box(1, { name: "box" })
observe(box, c => console.log(c.observableKind, c.debugObjectName), true)
box.set(2)
// before: "value box", then "undefined undefined"
// after:  "value box", then "value box"

The fix adds the two fields to the change object in ObservableValue.setNewValue_. The object is only built when a listener is registered, so nothing changes otherwise.

Code change checklist

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated (not needed, the docs already describe this behaviour)
  • Verified that there is no significant performance drop (npm -w mobx run test:performance) (the script is a shell script and I couldn't run it on Windows; the change adds two properties to an object that is only created when there are listeners)

@changeset-bot

changeset-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dbec9aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kubk
kubk merged commit 850b712 into mobxjs:main Nov 1, 2026
@kubk

kubk commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks

@github-actions github-actions Bot mentioned this pull request Nov 1, 2026
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.

2 participants