File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 11module Main where
22
3+ import Control.Monad.Eff
34import Debug.Trace
45import React
56import qualified React.DOM as DOM
67
8+ foreign import interval
9+ " function interval(ms) { \
10+ \ return function(action) { \
11+ \ return function() { return setInterval(action, ms); } \
12+ \ } \
13+ \}"
14+ :: forall eff r . Number -> Eff (trace :: Trace ) r -> Eff (eff ) { }
15+
716helloInConsole = do
817 props <- getProps
918 trace (" Hello, " ++ props.name ++ " !" )
@@ -22,7 +31,14 @@ incrementCounter = do
2231 val <- readState
2332 writeState (val + 1 )
2433
25- counter = mkUI spec { getInitialState = return 0 } do
34+ counter = mkUI spec {
35+ getInitialState = return 0 ,
36+ componentDidMount = do
37+ self <- getSelf
38+ interval 1000 $ runUI self do
39+ val <- readState
40+ print val
41+ } do
2642 val <- readState
2743 return $ DOM .p {
2844 className: " Counter" ,
You can’t perform that action at this time.
0 commit comments