Last active
August 2, 2016 18:02
-
-
Save perguth/c3429bf5f7d3df32e4f91a84030c7734 to your computer and use it in GitHub Desktop.
Playing around with Yoshs Choo.
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
const choo = require('choo') | |
const app = choo() | |
app.model({ | |
state: { title: 'Set the title' }, | |
reducers: { | |
update: (action, state) => ({ title: action.value }) | |
}, | |
subscriptions: [ | |
(send) => setInterval(() => {send('print', { payload: 'dog?' })}, 1000) | |
], | |
effects: { | |
print: (action) => { | |
console.log(action.payload) | |
} | |
} | |
}) | |
const mainView = (params, state, send) => choo.view` | |
<main> | |
<h1>${state.title}</h1> | |
<input | |
type="text" | |
oninput=${(e) => send('update', { value: e.target.value })}> | |
</main> | |
` | |
app.router((route) => [ | |
route('/', mainView) | |
]) | |
const tree = app.start() | |
document.body.appendChild(tree) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment