Closed jeffcarbs closed 8 years ago
Just squashed the commits and amended the last one. Initially the updates here allowed the normalized entities (during non-immutable usage) to be mutated. However, I realized this probably isn't ideal especially for people using this with redux since denormalized entities would wind up back in the store.
I added some specs failing specs to confirm and updated the functionality so they pass. It will now safely denormalize without mutating the passed entities.
If all goes well and this winds up getting merged, could you publish a new version to NPM? Thanks!
@gpbl - do you think you'll have a chance to review this over the weekend? I'm currently hard-coding this in a project of mine and would love avoid that 😄
I'm voting for this feature! Thanks @jcarbo for implementing
Published as 0.3.0 (with the immutable-js support as well). Thanks @jcarbo again 👍 please forgive me for the delay on merging it 🙏 I hope it didn't cause too much problems with your project!
Fixes #3
This PR updates the denormalize function to handle denormalizing lists when the schema is an
IterableSchema
(i.e.arrayOf(someEntitySchema)
). I did some refactoring as part of that work, and a nice side effect was being able to denormalize just by passing the id (or array of ids). This was already how denormalizing nested arrays was handled, so I think it makes sense to expose at the top level.A cool side effect is the greater symmetry with normalizr. This is now true: