Advertisement
Guest User

Untitled

a guest
Jun 17th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. const submit = require('some-submit-behavior')
  2. const choo = require('choo')
  3.  
  4. const validate = submit.validate
  5. const emit = submit.emit
  6. const app = choo()
  7.  
  8. const validator = validate({
  9. required: [ 'username' ],
  10. type: 'object',
  11. properties: {
  12. username: { type: 'string' },
  13. password: { type: 'string' }
  14. }
  15. })
  16.  
  17. // extends the model with a bunch of effects
  18. // and reducers. Namespace makes it so it's bound
  19. // and works anywhere
  20. app.model(validator({
  21. namespace: 'my-namespace'
  22. }))
  23.  
  24. app.router((route) => [
  25. route('/', (params, state, send) => {
  26. const view = choo.view`
  27. <form class="myForm">
  28. <input type="text" name="name" placeholder="name">
  29. <input type="text" name="address" placeholder="address">
  30. <input type="password" name="passphrase" placeholder="passphrase">
  31. <input type="submit" value="Submit">
  32. </form>
  33. `
  34. return emit('my-namespace', send, view)
  35. })
  36. ])
  37.  
  38. const tree = app.start()
  39. document.body.appendChild(tree)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement