Skip to content

Instantly share code, notes, and snippets.

@rbiggs
Last active November 15, 2018 15:27
Show Gist options
  • Select an option

  • Save rbiggs/cc6535d1edc7954e24c75b5e22c47ac1 to your computer and use it in GitHub Desktop.

Select an option

Save rbiggs/cc6535d1edc7954e24c75b5e22c47ac1 to your computer and use it in GitHub Desktop.
@composi/core runtime program -- Counter
// Counter for view:
function Counter({state, send}) {
return (
<p>
<button onclick={() => history.go(0)} id='reload-btn'>Restart</button>
<button class='counter' onclick={() => send()}>{state}</button>
</p>
)
}
// Assemble program together:
const program = {
init() {
return [0]
},
view(state, send) {
render(<Counter {...{state, send}} />, document.body)
},
update(msg, state) {
return [state + 1]
}
}
// Run the program:
run(program)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment