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

Use with Maps and Sets #1

Open
bsbechtel opened this issue Mar 2, 2017 · 10 comments
Open

Use with Maps and Sets #1

bsbechtel opened this issue Mar 2, 2017 · 10 comments

Comments

@bsbechtel
Copy link

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.

@johndevor
Copy link

+1 this question

@capaj
Copy link
Owner

capaj commented Mar 17, 2017

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.

@capaj capaj added this to the 0.9.6 milestone Mar 17, 2017
@johndevor
Copy link

I'm trying to put together something for this...

@johndevor
Copy link

Dumb question, but when you're referring to "Sets" in javascript, you're talking about associative arrays, correct?

@johndevor
Copy link

Also, what do you guys think of a method signature like this?

function storedObservable (key, defaultValue, debounce = 500, type)

@capaj
Copy link
Owner

capaj commented Mar 30, 2017

@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.

@johndevor
Copy link

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

@capaj
Copy link
Owner

capaj commented Mar 30, 2017

@johndevor I was thinking more like:

const defaultMap = new Map()
defaultMap.set('myMapKey', 1)
storedObservable('text', defaultMap, 500)

@johndevor
Copy link

johndevor commented Mar 30, 2017 via email

@capaj capaj removed this from the 0.9.6 milestone Apr 6, 2017
@johndevor
Copy link

Haven't had time to get to this if anybody wants to take a stab at it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants