Guest User

Untitled

a guest
Nov 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import { run } from '@composi/core'
  2.  
  3. const program = {
  4. // Handle initialization by setting state
  5. // and running a subscription (effect) at startup.
  6. init() {
  7. return [state, effect]
  8. },
  9. // The view handles state and provides the UI with
  10. // a send function for dispatching messages to Update.
  11. view(state, send) {
  12. // Render a component:
  13. return render(Component(state, send), document.body)
  14. },
  15. update(msg, state) {
  16. // action based on message type:
  17. if (msg.type === 'add-item') {
  18. state.push(msg.data)
  19. }
  20. // When done, return state and
  21. // optionally run an effect:
  22. return [state, effect]
  23. }
  24. }
  25.  
  26. // Run the program:
  27. run(program)
Add Comment
Please, Sign In to add comment