Skip to content

Instantly share code, notes, and snippets.

@rajatk16
Created July 26, 2018 05:20
Show Gist options
  • Select an option

  • Save rajatk16/262f2d6be2e89974a9d4d152069b2898 to your computer and use it in GitHub Desktop.

Select an option

Save rajatk16/262f2d6be2e89974a9d4d152069b2898 to your computer and use it in GitHub Desktop.
(function(root) {
const { get, modify } = crocks.State
const { constant } = crocks
const add =
x => y => x + y
const inc =
add(1)
const multiply =
x => y => x * y
const addState = n =>
get(add(n))
const incState = n =>
modify(inc)
.map(constant(n))
const multiplyState = n =>
get(multiply(n))
root.helpers = {
addState,
incState,
multiplyState
}
})(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment