Skip to content

Instantly share code, notes, and snippets.

@nelix
Created March 21, 2015 03:22
Show Gist options
  • Save nelix/e867cc96630191bdd53a to your computer and use it in GitHub Desktop.
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
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