Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const submit = require('some-submit-behavior')
- const choo = require('choo')
- const validate = submit.validate
- const emit = submit.emit
- const app = choo()
- const validator = validate({
- required: [ 'username' ],
- type: 'object',
- properties: {
- username: { type: 'string' },
- password: { type: 'string' }
- }
- })
- // extends the model with a bunch of effects
- // and reducers. Namespace makes it so it's bound
- // and works anywhere
- app.model(validator({
- namespace: 'my-namespace'
- }))
- app.router((route) => [
- route('/', (params, state, send) => {
- const view = choo.view`
- <form class="myForm">
- <input type="text" name="name" placeholder="name">
- <input type="text" name="address" placeholder="address">
- <input type="password" name="passphrase" placeholder="passphrase">
- <input type="submit" value="Submit">
- </form>
- `
- return emit('my-namespace', send, view)
- })
- ])
- const tree = app.start()
- document.body.appendChild(tree)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement