mobx-stored
mobx-stored copied to clipboard
Use with Maps and Sets
Can this library be used with JavaScript Maps and Sets? I'm not having any luck adding values to a Set used in the store.
+1 this question
oh yeah, it won't work. I will add support for them in milestones 0.9.6. Will have to store a type information somewhere but that should not be that hard.
I'm trying to put together something for this...
Dumb question, but when you're referring to "Sets" in javascript, you're talking about associative arrays, correct?
Also, what do you guys think of a method signature like this?
function storedObservable (key, defaultValue, debounce = 500, type)
@johndevor that's a good question. We should definitely support a Map because MobX has it's observable counterpart implemented already. When it comes to Sets, I am no really sure.
In regards to the the type- we can easily recognize it from the default value so there's no need for programmer to hint the type via en extra parameter.
How do you recognize the difference between an obj and a map in these cases?
storedObservable('text', {'myObjKey':1}, 500)
storedObservable('text', {'myMapKey':1}, 500)
Both of the default values appear to be similar objects to me. Unless you had in mind changing the method signature entirely to something like:
storedMapObservable
@johndevor I was thinking more like:
const defaultMap = new Map()
defaultMap.set('myMapKey', 1)
storedObservable('text', defaultMap, 500)
Ah yes of course. 👍
On Thu, Mar 30, 2017, 11:35 AM Jiri Spac [email protected] wrote:
@johndevor https://github.com/johndevor I was thinking more like:
const defaultMap = new Map()defaultMap.set('myMapKey', 1)storedObservable('text', defaultMap, 500)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/capaj/mobx-stored/issues/1#issuecomment-290449614, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEoM5vEsbRl0UlxtRnZTvoEumOWGOKhks5rq8vXgaJpZM4MRBw0 .
Haven't had time to get to this if anybody wants to take a stab at it...