haskell - ghcjs + sodium: no events after some time -
update: there issue in ghcjs: https://github.com/ghcjs/ghcjs/issues/296
i play ghcjs , sodium after 3 seconds application doesn't emit events anymore.
a minimal example:
- a button: emit events
- a counter behavior: counts button clicks
- a div: displays counter behavior
- after 3 seconds, div doesn't update anymore
- if reload page, counter updates again - 3 seconds
{-# language overloadedstrings #-} module main import control.applicative ((<$>)) import control.concurrent (forkio, threaddelay) import control.monad (forever) import data.default (def) import data.text (text, pack) import frp.sodium import javascript.jquery hiding (event) main :: io () main = body <- select "body" -- button (btn, btne) <- mkbtne "click" appendjquery btn body -- behavior: counter - increment when btne (button event) arrive counterb <- sync $ accum 0 (const (+1) <$> btne) -- div counter value counterview <- mkdiv $ fmap (pack . show) counterb appendjquery counterview body -- wait -> nothing changed -- forkio $ forever (threaddelay 1000000000) return () mkbtn :: text -> io jquery mkbtn label = select "<button/>" >>= settext label mkbtne :: text -> io (jquery, event ()) mkbtne label = (e, t) <- sync newevent btn <- mkbtn label on (const $ sync $ t ()) "click" def btn return (btn, e) mkdiv :: behaviour text -> io jquery mkdiv b = div <- select "<div/>" sync $ listen (value b) (\t -> settext t div >> return ()) return div
the full example under https://github.com/j-keck/ghcjs-sodium
thanks
Comments
Post a Comment