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

Allow Symbol keys in observable maps (fixes #1925) #1930

Merged
merged 1 commit into from
Mar 30, 2019
Merged

Allow Symbol keys in observable maps (fixes #1925) #1930

merged 1 commit into from
Mar 30, 2019

Conversation

pimterry
Copy link
Contributor

@pimterry pimterry commented Mar 14, 2019

  • Added unit tests
  • Updated changelog
    • Not clear what the 'right' way to do this is, seems lots of PRs ignore it? I've added an 'Unreleased' section ready to rename for the next release for now.
  • Updated docs (either in the description of this PR as markdown, or as separate PR on the gh-pages branch. Please refer to this PR). For new functionality, at least API.md should be updated
    • No changes necessary imo
  • Added typescript typings
    • No types have changed
  • Verified that there is no significant performance drop (npm run perf)

@mweststrate you mentioned safeStringify in #1925, I couldn't find that - looks like it's a function in the mobx-state-tree codebase?

I've written a separate key stringification function instead. Here it actually doesn't use JSON.stringify, because JSON can't represent symbols, and they're normally omitted from JSON stringified objects. For the same reason, I've also preserved symbol-ness in toPOJO here, instead of stringifying them, which feels correct, and helpfully means we get the correct behaviour (symbol keys omitted) in toJSON here too.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 93.877% when pulling 9f12565 on pimterry:symbol-map-keys into 4451340 on mobxjs:master.

@pimterry
Copy link
Contributor Author

@mweststrate any thoughts on this one? I'd love to get this fix in.

@mweststrate
Copy link
Member

@pimterry looking great! Merging and releasing. I think this should be pack-ported to mobx4 too?

@mweststrate mweststrate merged commit 78db110 into mobxjs:master Mar 30, 2019
@mweststrate
Copy link
Member

Backported, released as 4.9.4 / 5.9.4

@pimterry
Copy link
Contributor Author

Amazing, thank you!

@pimterry pimterry deleted the symbol-map-keys branch March 30, 2019 13:57
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.

3 participants