Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't pass undefined to custom equality checks on becoming observed a… #1213

Merged
merged 2 commits into from
Nov 1, 2017
Merged

Conversation

chrisdoble
Copy link

…gain

This PR attempts to fix #1208.

I've extended one of the tests added in #951 to cover this bug, but I'm not sure if that's sufficient. The difference between test/babel/*.js, test/typescript/*.js, and test/*.js isn't clear to me so please let me know if I should add more tests.

PR checklist:

  • Added unit tests
  • Verified that there is no significant performance drop (npm run perf)

@@ -682,7 +682,7 @@ test("peeking inside autorun doesn't bork (global) state", t => {
t.equal(b.diffValue, 0)
t.equal(b.lowestObserverState, 0)
t.equal(b.unboundDepsCount, 1)
t.equal(b.value, undefined)
t.notEqual(b.value, 3)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly happy with this assertion. I wanted to write something like t.ok(isCaughtException(b.value)) but as far as I can tell neither CaughtException nor isCaughtException are exported from mobx.ts. I considered exporting them from mobx.ts, but that's changing public API. Also considered importing them from core/derivation.ts directly, but that's inconsistent with all other tests.

This feels like it's still achieving the goal of the assertion (ensuring that the cached value is cleared) while avoiding those problems.

I'm open to suggestions of other approaches.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.649% when pulling 89959b0 on chrisdoble:1208 into ea6c823 on mobxjs:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.649% when pulling 9c98b85 on chrisdoble:1208 into ea6c823 on mobxjs:master.

@mweststrate mweststrate merged commit 9c98b85 into mobxjs:master Nov 1, 2017
@mweststrate
Copy link
Member

Made a minor improvement and merged. Thanks!

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.

Non-value passed to custom computed equality check
3 participants