Skip to content

Instantly share code, notes, and snippets.

@joedski
Last active September 27, 2017 01:15
Show Gist options
  • Save joedski/6a3887d67d17a0370012e484334ca263 to your computer and use it in GitHub Desktop.
Save joedski/6a3887d67d17a0370012e484334ca263 to your computer and use it in GitHub Desktop.
comp-undo-steps 2: Using compose to flatten things out.
const processFoo = compose(
stepA(optionsA),
stepB(optionsB),
stepC(optionsC)
)(res => res);
async function handleSomeThing(ctx) {
// Create a pctx with the original ctx and whatever else we want.
// NOTE: in this case, we're trying to not pollute the original ctx,
// which might be something like a Koa Context.
const pctx = { ctx };
const resultPctx = await processFoo(pctx);
return resultPctx.resultFoo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment