Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. module ClickCounter where
  2.  
  3. import Prelude
  4. import Component as C
  5. import Pux.Html as H
  6. import Pux.Html.Events as E
  7. import Data.Generic (class Generic)
  8.  
  9. type State = Int
  10.  
  11. data Action = Click
  12. derive instance genericAction :: Generic Action
  13.  
  14. initialState :: State
  15. initialState = 0
  16.  
  17. component :: ∀ e. C.PuxComponent Action State e
  18. component = C.Simple update view
  19. where
  20. update Click s = s + 1
  21. view s = H.div [] [
  22. H.strong [] [H.text "Count your clicks"],
  23. H.div [] [H.text $ "you have clicked " ++ show s ++ " times."],
  24. H.button [E.onClick $ const Click] [H.text "click"]
  25. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement