-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Mobx 4] Make ObservableMap work with non-string keys (like es6 Map does) #800
Conversation
@andykog great stuff! Some concerns / questions on compatibility:
|
|
|
Agree |
very much yes! |
@capaj, @mweststrate, what worrying me is that it makes tuff to convert data containing maps to json/POJOs with
|
@andykog IMHO if you're using maps for their dynamic keys and rely on the map being converted to object when you do To sum up, ObservableMaps should not be misused as "dynamic objects". |
Out of interest, can we assume this'll make MobX 4 when that lands? It'd be very handy. Would it become the new 'default' map-type with the current string-keyed map being renamed? |
Just found this issue when I was trying to replicate a bug! I've been using ES6 Map's enough I have this hard-wired behaviour to always convert strings to keys before I call set/get, but I deleted that out of interest and... everything still worked! I'm probably in the minority here, but I have been constructing things using Mind you, guaranteeing stringed keys is pretty useful most of the time, and it feels much less surprising if you're constructing it with Btw, a common area where this can bite you is if you index into a collection based off a JSON response (integer) as well as a React Router url fragment (string). Anyway, I'm sure you're all on top of this just wanted to let you know my experience. |
|
Played around with it a bit, doesn't seems to be any performance losses, so why not?
(Will add some overpatching, test, docs, if this is going to be accepted.)
Not sure about:
toJS
return Map instead of object (breaking change)?