Files
buuh/examples/title.js
T

31 lines
671 B
JavaScript
Raw Normal View History

2016-05-11 13:51:17 +07:00
const choo = require('../')
const app = choo()
app.model('title', {
state: { title: 'my-demo-app' },
reducers: {
'update': (action, state) => ({ title: action.payload })
},
effects: {
2016-05-11 14:56:18 +07:00
'update': (action, state, send) => (document.title = action.payload)
2016-05-11 13:51:17 +07:00
}
})
const mainView = (params, state, send) => choo.view`
<main class="app">
<h1>${state.title}</h1>
<label>Set the title</label>
<input
type="text"
placeholder=${state.title}
oninput=${(e) => send('title:update', { payload: e.target.value })}>
</main>
`
app.router((route) => [
route('/', mainView)
])
2016-05-11 14:56:18 +07:00
const tree = app.start()
document.body.appendChild(tree)