Skip to content

Instantly share code, notes, and snippets.

@vdsabev
Last active August 15, 2017 13:27
Show Gist options
  • Save vdsabev/914c42de0618a561e850450c79ab6def to your computer and use it in GitHub Desktop.
Save vdsabev/914c42de0618a561e850450c79ab6def to your computer and use it in GitHub Desktop.
Exploring Unidirectional Components in Mithril
app({
state: {
count: 0
},
actions: {
decrement: ({ count }) => ({ count: count - 1 }),
increment: ({ count }) => ({ count: count + 1 })
},
view: ({ count }, { decrement, increment }) =>
<div>
<h1>{count}</h1>
<button onclick={decrement} disabled={count <= 0}>-</button>
<button onclick={increment}>+</button>
</div>
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment