Last active
January 11, 2017 06:58
-
-
Save justingreenberg/0e5be83b1bacd4d3cb1b943a88ab9dbe to your computer and use it in GitHub Desktop.
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
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