main.esl 788 B

1234567891011121314151617181920212223242526272829
  1. (lambda start-main-loop (app)
  2. ; set up automatic updates
  3. (Glagol.events.on "changed" (lambda (node)
  4. (if (=== node.path "/main.esl")
  5. (window.location.reload))
  6. (if (=== (- node.path.length 5) (node.path.lastIndexOf ".styl")) (block
  7. (css.parent-element.remove-child css)
  8. (= css (/lib/insert-css ./styles/index))))
  9. (if (=== 0 (node.path.index-of "/templates"))
  10. (view.update (/state)))))
  11. ; establish connection with api
  12. (/events/app/connect)
  13. ; insert css first to prevent fouc
  14. (var css (/lib/insert-css ./styles/index))
  15. ; start vdom main loop
  16. (var view (/lib/riko/V /state /templates/app))
  17. (= document.body.innerHTML "")
  18. (document.body.append-child view.target)
  19. ; load data from server
  20. (/events/session/init)
  21. (return view))