rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.36k stars 194 forks source link

Does not work with Javascript Maps #171

Open noahehall opened 7 years ago

noahehall commented 7 years ago

I am using a javacript map to store data I retrieve from an api for a udacity project.

However, the data is not being saved to the immutable object.

here is a branch you can clone and verify:

  1. clone https://github.com/noahehall/udacity-trainschedule/tree/serviceworkers
  2. npm install
  3. npm run start

here is picture of implementation

screen shot 2016-11-13 at 9 51 18 pm

here is picture of error received from immutable

screen shot 2016-11-13 at 9 53 16 pm

error TypeError: immutableDoesNotWorkWithJavascriptMaps.data.has is not a function(…)

Is there a workaround to get immutable to use Javascript maps? am i doing something wrong (very likely...)? or should I abandon seamless immutable?

noahehall commented 7 years ago

hmm ive actually switched form using Maps with seamless-immutable, but will be interested to know if they will be supported in the future

rtfeldman commented 7 years ago

Happy to accept a PR for them!

noahehall commented 7 years ago

Definitely, ill take a swing at it. I switched to storing everything as an object for now

gavin-gmlab commented 7 years ago

I'm having this problem also.

Seems like a .set still works, but a .get does not get the object back properly.

Tried a workaround to create a new map object => newMap = new Map(state.oldMap._mapData) seems to work. Not sure if there are other implications

noahehall commented 7 years ago

yeah sorry guys still havent had time to work on this, things at work have been crazy

noahehall commented 7 years ago

Finally got some time, picking this up ;)

noahehall commented 7 years ago

so i got drunk last night and worked on integrating maps,

you can see a preview here: https://github.com/rtfeldman/seamless-immutable/pull/198

i'll need to do some clean up and refacter it a bit, add some tests, then ill drop the WIP tag from the pull request

mikeaustin commented 6 years ago

Soo.. are Maps and Sets supported now? I'd digging around trying to find out.

tedlin182 commented 4 years ago

@noahehall Any progress on this?