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 1
1
module Main where
2
2
3
+ import Control.Monad.Eff
3
4
import Debug.Trace
4
5
import React
5
6
import qualified React.DOM as DOM
6
7
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
+
7
16
helloInConsole = do
8
17
props <- getProps
9
18
trace (" Hello, " ++ props.name ++ " !" )
@@ -22,7 +31,14 @@ incrementCounter = do
22
31
val <- readState
23
32
writeState (val + 1 )
24
33
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
26
42
val <- readState
27
43
return $ DOM .p {
28
44
className: " Counter" ,
You can’t perform that action at this time.
0 commit comments