Skip to content

Commit

Permalink
Adapt the todo example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Drup committed Nov 7, 2015
1 parent c7b191b commit 0278b27
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions examples/todo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,9 @@ module View = struct
| false, _ -> None)

let items k =
selectAll "li"
|. data (fun m _ -> items_of_model m)
|- nest enter
[ append "li"
|. E.dblclick (fun _ _ i -> k (Event.Edit i)) ]
data "li" (fun m _ -> items_of_model m)
|- nest (enter "li")
[ E.dblclick (fun _ _ i -> k (Event.Edit i)) ]
|- nest update
[ classed "editing" (fun _ m i -> m.editing)
; classed "completed" (fun _ m i -> m.completed)
Expand Down Expand Up @@ -227,20 +225,18 @@ module View = struct
[ exit <.> remove ]

let filters k =
selectAll "li"
|. data (fun m _ ->
let open Model in
[ (All , m.filter = All , "#/")
; (Active , m.filter = Active , "#/active")
; (Completed, m.filter = Completed, "#/completed")
])
|- nest enter
[ append "li"
|. append "a"
|. attr "href" (fun _ (_, _, href) _ -> href)
|. text (fun _ (f, _, _) _ -> Model.string_of_filter f) ]
data "li" (fun m _ ->
let open Model in
[ (All , m.filter = All , "#/")
; (Active , m.filter = Active , "#/active")
; (Completed, m.filter = Completed, "#/completed")
])
|- nest (enter "li")
[ append "a"
|. attr "href" (fun _ (_, _, href) _ -> href)
|. text (fun _ (f, _, _) _ -> Model.string_of_filter f) ]
|- nest update
[ select "a"
[ data "a" (fun d _ -> [d])
|. classed "selected" (fun _ (_, active, _) _ -> active) ]
|. E.click (fun _ (f,_,_) _ -> k (Event.Filter f))
|- nest exit
Expand Down

0 comments on commit 0278b27

Please sign in to comment.