Skip to content

Instantly share code, notes, and snippets.

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