Last active
August 15, 2017 13:27
-
-
Save vdsabev/914c42de0618a561e850450c79ab6def to your computer and use it in GitHub Desktop.
Exploring Unidirectional Components in Mithril
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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