@@ -33,9 +33,8 @@ type button_labels =
3333
3434[%% client.start]
3535
36- open Lwt.Syntax
3736open Js_of_ocaml
38- open Js_of_ocaml_lwt
37+ open Js_of_ocaml_eio
3938
4039let default_intl =
4140 { i_days = [" S" ; " M" ; " T" ; " W" ; " T" ; " F" ; " S" ]
@@ -178,12 +177,20 @@ let zeroth_displayed_day ~intl d =
178177 then o
179178 else CalendarLib.Date. prev o `Week
180179
181- let select_action ?(size = 1 ) selector action =
180+ let select_action
181+ ?(size = 1 )
182+ selector
183+ (action :
184+ ?cancel_handler:bool
185+ -> ?use_capture:bool
186+ -> ?passive:bool
187+ -> 'a
188+ -> ('b -> unit)
189+ -> unit )
190+ =
182191 let dom_select = Eliom_content.Html.To_dom. of_select selector in
183- Lwt. async (fun () ->
184- action dom_select (fun _ _ ->
185- dom_select##.size := size;
186- Lwt. return_unit))
192+ Eliom_lib. fork (fun () ->
193+ action dom_select (fun _ -> dom_select##.size := size))
187194
188195let rec build_calendar
189196 ?prehilight
@@ -227,7 +234,7 @@ let rec build_calendar
227234 else option ~a: [a_value y] (txt y)))
228235 in
229236 let () =
230- let open Lwt_js_events in
237+ let open Eio_js_events in
231238 let size = 10 in
232239 select_action select_year mousedowns ~size ;
233240 select_action select_year changes;
@@ -356,19 +363,15 @@ let attach_events
356363 and y = CalendarLib.Calendar.Date. year d in
357364 let action =
358365 match action with
359- | Some action ->
360- fun _ r ->
361- update_classes cal zero d;
362- let * _ = action y m dom in
363- Lwt. return_unit
364- | None -> fun _ r -> update_classes cal zero d; Lwt. return_unit
366+ | Some action -> fun _ -> update_classes cal zero d; action y m dom
367+ | None -> fun _ -> update_classes cal zero d
365368 in
366369 let set_onclick () =
367370 if in_period d ~begin_p: period.begin_p ~end_p: period.end_p
368371 then
369- let f () = Lwt_js_events . clicks c action in
370- Lwt. async f
371- else Lwt. async ( fun () -> Lwt. return_unit )
372+ let f () = Eio_js_events . clicks c action in
373+ Eliom_lib. fork f
374+ else ( )
372375 in
373376 if List. exists (( = ) dom) highlight
374377 then (
@@ -378,7 +381,7 @@ let attach_events
378381 then set_onclick ()
379382 else ()
380383
381- let attach_events_lwt
384+ let attach_events_async
382385 ?action
383386 ?click_non_highlighted
384387 ~intl
@@ -390,11 +393,10 @@ let attach_events_lwt
390393 let f () =
391394 let m = CalendarLib.Date. (month d |> int_of_month)
392395 and y = CalendarLib.Date. year d in
393- let * highlight = highlight y m in
394- attach_events ?action ?click_non_highlighted ~intl ~period d cal highlight;
395- Lwt. return_unit
396+ let highlight = highlight y m in
397+ attach_events ?action ?click_non_highlighted ~intl ~period d cal highlight
396398 in
397- Lwt. async f
399+ Eliom_lib. fork f
398400
399401let make_span_handler
400402 selector
@@ -444,7 +446,7 @@ let attach_behavior
444446 =
445447 (match highlight with
446448 | Some highlight ->
447- attach_events_lwt ?click_non_highlighted ?action ~intl ~period d cal
449+ attach_events_async ?click_non_highlighted ?action ~intl ~period d cal
448450 highlight
449451 | None -> attach_events ?click_non_highlighted ?action ~intl ~period d cal [] );
450452 let s_y = To_dom. of_select select_year in
@@ -503,10 +505,10 @@ let attach_behavior
503505
504506let make :
505507 ?init :int * int * int
506- -> ?highlight :(int -> int -> int list Lwt. t )
508+ -> ?highlight :(int -> int -> int list )
507509 -> ?click_non_highlighted :bool
508510 -> ?update :(int * int * int ) React.E. t
509- -> ?action :(int -> int -> int -> unit Lwt. t )
511+ -> ?action :(int -> int -> int -> unit )
510512 -> ?period :
511513 CalendarLib.Date. field CalendarLib.Date. date
512514 * CalendarLib.Date. field CalendarLib.Date. date
@@ -551,7 +553,7 @@ let make :
551553 let f (y , m , d ) =
552554 CalendarLib.Date. make_year_month y m |> f_d_ym;
553555 match action with
554- | Some action -> Lwt. async (fun () -> action y m d)
556+ | Some action -> Eliom_lib. fork (fun () -> action y m d)
555557 | None -> ()
556558 in
557559 Eliom_lib.Dom_reference. retain (To_dom. of_element elt)
@@ -599,11 +601,7 @@ let%shared make_date_picker ?init ?update ?button_labels ?intl ?period () =
599601 CalendarLib.Date. (year d, month d |> int_of_month, day_of_month d)
600602 in
601603 let v, f = Eliom_shared.React.S. create init in
602- let action =
603- [% client
604- fun y m d ->
605- ~% f (y, m, d);
606- Lwt. return_unit]
604+ let action = [% client fun y m d -> ~% f (y, m, d)]
607605 and click_non_highlighted = true in
608606 let d =
609607 make ~init ~click_non_highlighted ?update ?button_labels ?intl ?period
0 commit comments