Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Last active December 4, 2017 05:45
Show Gist options
  • Save ccapndave/b6d9e61ecf45322fe8115f19783598d6 to your computer and use it in GitHub Desktop.
Save ccapndave/b6d9e61ecf45322fe8115f19783598d6 to your computer and use it in GitHub Desktop.
// 1. Very functional but hard to read
const newState = stateTransformers.reduce((s, stateTransformer) => s.then(stateTransformer), Promise.resolve(state));
// 2. Easy to read, but has mutation
let state = startingState;
for (let stateTransfomer of stateTransformers) {
state = await stateTransfomer(state);
}
// 3. ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment