Skip to content

Instantly share code, notes, and snippets.

@justingreenberg
Last active January 11, 2017 06:58
Show Gist options
  • Save justingreenberg/0e5be83b1bacd4d3cb1b943a88ab9dbe to your computer and use it in GitHub Desktop.
Save justingreenberg/0e5be83b1bacd4d3cb1b943a88ab9dbe to your computer and use it in GitHub Desktop.
import assert from 'assert'
import Immutable from 'immutable'
const batchSetters = state => {
state.set('a', 1)
state.set('b', 2)
state.set('c', 3)
return state
}
const immutableState = () => Immutable.fromJS({ a: 0, b: 0, c: 0 })
const normal = batchSetters(immutableState())
const batched = immutableState().withMutations(batchSetters)
const expected = { a: 1, b: 2, c: 3 }
assert.equal(normal.toJS(), expected, 'normal')
assert.equal(batched.toJS(), expected, 'batched')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment