Question: Using OrderedMap.merge to translate Objects to OrderedMaps instead of Maps?

Question

Using OrderedMap.merge to translate Objects to OrderedMaps instead of Maps?

Answers 1
Added at 2016-07-02 16:07
Tags
Question

I'm trying to use OrderedMap.merge to store application state using reflux (specifically reflux-immutable), but I noticed this does not translate Objects into OrderedMaps, but regular Maps, which do not guarantee order when iterated over. There are several parts of my application where I need order to be retained, so I was wondering if there was a way to accomplish this using OrderedMap.merge or something like merge. I came up with this, but it's super ugly and relies on ripping source code out of Immutable.js, which I'm not comfortable with.

Does anyone have any other ideas? Thanks in advance.

Answers to

Using OrderedMap.merge to translate Objects to OrderedMaps instead of Maps?

nr: #1 dodano: 2016-07-05 16:07

I decided to solve this problem a different way, namely by explicitly converting the objects I needed to be ordered maps prior to invoking OrderedMap.merge on the entire store's state. This works because the definition of merge essentially ignores objects that are already immutable, so there's no risk of duplicate work and merge's functionality is retained without having to do all the silly hacked together stuff I was doing.

Source Show
◀ Wstecz