使用 OrderedMap.merge 将对象转换为 OrderedMaps 而不是 Maps?
Using OrderedMap.merge to translate Objects to OrderedMaps instead of Maps?
我正在尝试使用 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,但它非常丑陋并且依赖于从 Immutable.js 中提取源代码,我对此感到不舒服。
还有人有其他想法吗?提前致谢。
我决定以不同的方式解决这个问题,即在对整个商店的状态调用 OrderedMap.merge 之前,通过显式转换我需要有序映射的对象。这是可行的,因为 merge 的定义基本上忽略了已经不可变的对象,因此没有重复工作的风险,并且保留了 merge 的功能,而不必做我正在做的所有愚蠢的黑客攻击。
我正在尝试使用 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,但它非常丑陋并且依赖于从 Immutable.js 中提取源代码,我对此感到不舒服。
还有人有其他想法吗?提前致谢。
我决定以不同的方式解决这个问题,即在对整个商店的状态调用 OrderedMap.merge 之前,通过显式转换我需要有序映射的对象。这是可行的,因为 merge 的定义基本上忽略了已经不可变的对象,因此没有重复工作的风险,并且保留了 merge 的功能,而不必做我正在做的所有愚蠢的黑客攻击。