1234567891011121314151617181920212223242526272829 |
- (lambda start-main-loop (app)
- ; set up automatic updates
- (Glagol.events.on "changed" (lambda (node)
- (if (=== node.path "/main.esl")
- (window.location.reload))
- (if (=== (- node.path.length 5) (node.path.lastIndexOf ".styl")) (block
- (css.parent-element.remove-child css)
- (= css (/lib/insert-css ./styles/index))))
- (if (=== 0 (node.path.index-of "/templates"))
- (view.update (/state)))))
- ; establish connection with api
- (/events/app/connect)
- ; insert css first to prevent fouc
- (var css (/lib/insert-css ./styles/index))
- ; start vdom main loop
- (var view (/lib/riko/V /state /templates/app))
- (= document.body.innerHTML "")
- (document.body.append-child view.target)
- ; load data from server
- (/events/session/init)
- (return view))
|