-
-
Save nelix/e867cc96630191bdd53a to your computer and use it in GitHub Desktop.
Turn some json (with id props) into an OrderedSet of Records with ImmutableJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThingRecord extends Immutable.Record({ | |
id: null, | |
someData: {} | |
}) {} | |
const thingSet = Immutable.fromJS(things); | |
const thingsOrderedMap = thingSet.reduce((r, v) => r.set(v.get('id'), | |
new ThingRecord(v)), | |
Immutable.OrderedMap() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment