diff --git a/src/widgets/ot_calendar.eliom b/src/widgets/ot_calendar.eliom index 4f0efde3..9841913e 100644 --- a/src/widgets/ot_calendar.eliom +++ b/src/widgets/ot_calendar.eliom @@ -561,10 +561,10 @@ let make : let%server make : ?init:int * int * int - -> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t + -> ?highlight:(int -> int -> int list) Eliom_client_value.t -> ?click_non_highlighted:bool -> ?update:(int * int * int) React.E.t Eliom_client_value.t - -> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t + -> ?action:(int -> int -> int -> unit) Eliom_client_value.t -> ?period: CalendarLib.Date.field CalendarLib.Date.date * CalendarLib.Date.field CalendarLib.Date.date diff --git a/src/widgets/ot_calendar.eliomi b/src/widgets/ot_calendar.eliomi index 6e72fd32..2f56cc5f 100644 --- a/src/widgets/ot_calendar.eliomi +++ b/src/widgets/ot_calendar.eliomi @@ -41,10 +41,10 @@ type button_labels = val make : ?init:int * int * int - -> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t + -> ?highlight:(int -> int -> int list) Eliom_client_value.t -> ?click_non_highlighted:bool -> ?update:(int * int * int) React.E.t Eliom_client_value.t - -> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t + -> ?action:(int -> int -> int -> unit) Eliom_client_value.t -> ?period: CalendarLib.Date.field CalendarLib.Date.date * CalendarLib.Date.field CalendarLib.Date.date diff --git a/src/widgets/ot_carousel.eliom b/src/widgets/ot_carousel.eliom index fd76dc66..a2f94202 100644 --- a/src/widgets/ot_carousel.eliom +++ b/src/widgets/ot_carousel.eliom @@ -1,3 +1,5 @@ +open Eio.Std + (* Ocsigen * http://www.ocsigen.org * @@ -39,7 +41,7 @@ open%client Js_of_ocaml [%%client open Js_of_ocaml_lwt] [%%shared open Eliom_content.Html] [%%shared open Eliom_content.Html.F] -[%%shared open Lwt.Syntax] +[%%shared] let%client clX = Ot_swipe.clX let%client clY = Ot_swipe.clY @@ -587,9 +589,7 @@ let%client set_default_fail f = :> exn -> Html_types.div_content Eliom_content.Html.elt) let%shared generate_content generator = - Lwt.catch - (fun () -> Eliom_shared.Value.local generator ()) - (fun e -> Lwt.return (default_fail e)) + try Eliom_shared.Value.local generator () with e -> default_fail e (* on the client side we generate the contents of the initially visible page asynchronously so the tabs will be rendered right away *) @@ -606,8 +606,8 @@ let%client generate_initial_contents ~spinner sleeper gen = (* on the server side we generate all the visible contents right away *) let%server generate_initial_contents ~spinner:_ _ gen = - let* contents = generate_content gen in - Lwt.return (contents, ref @@ None) + let contents = generate_content gen in + contents, ref @@ None let%shared make_lazy @@ -628,30 +628,30 @@ let%shared = let gen_contents = (gen_contents - :> (unit -> Html_types.div_content elt Lwt.t) Eliom_shared.Value.t list) + :> (unit -> Html_types.div_content elt) Eliom_shared.Value.t list) + in + let sleeper, wakener = + Promise.create + (* TODO: ciao-lwt: Translation is incomplete, [Promise.await] must be called on the promise when it's part of control-flow. *) + () in - let sleeper, wakener = Lwt.wait () in - let mk_contents : int -> 'gen -> ('a elt * ('a elt * 'gen) option ref) Lwt.t = + let mk_contents : int -> 'gen -> 'a elt * ('a elt * 'gen) option ref = fun i gen -> if i = position then generate_initial_contents ~spinner sleeper gen else - Lwt.return - @@ let s = spinner () in s, ref @@ Some (s, gen) in - let* contents, spinners_and_generators = - Lwt.map List.split - @@ Lwt_list.map_s (fun x -> x) - @@ List.mapi mk_contents gen_contents + let contents, spinners_and_generators = + List.split (List.map (fun x -> x) (List.mapi mk_contents gen_contents)) in let carousel = make ?a ?vertical ~position ?transition_duration ?inertia ?swipeable ?allow_overswipe ?update ?disabled ?full_height ?make_transform ?make_page_attribute contents in - Lwt.wakeup wakener carousel.elt; + Promise.resolve wakener carousel.elt; (* generate initial content (client-side) *) (* replace spinners with content when switched to for the first time *) let _ = @@ -677,7 +677,7 @@ let%shared | None -> Lwt.return ()) : unit)] in - Lwt.return carousel + carousel let%shared bullet_class i pos size = Eliom_shared.React.S.l2 diff --git a/src/widgets/ot_carousel.eliomi b/src/widgets/ot_carousel.eliomi index d2424bf7..0bd09c1a 100644 --- a/src/widgets/ot_carousel.eliomi +++ b/src/widgets/ot_carousel.eliomi @@ -148,10 +148,10 @@ val make_lazy : -> Html_types.div_attrib Eliom_content.Html.D.attrib list) Eliom_shared.Value.t -> ?spinner:(unit -> Html_types.div_content Eliom_content.Html.elt) - -> (unit -> [< Html_types.div_content] Eliom_content.Html.elt Lwt.t) + -> (unit -> [< Html_types.div_content] Eliom_content.Html.elt) Eliom_shared.Value.t list - -> [> `Div] t Lwt.t + -> [> `Div] t (** same as [make] except for the last argument. Instead of supplying the contents for each page directly, supply a for each page a shared content generator function. Contents will be generated and filled lazily, i.e. when diff --git a/src/widgets/ot_drawer.eliom b/src/widgets/ot_drawer.eliom index 6703b24e..65644e41 100644 --- a/src/widgets/ot_drawer.eliom +++ b/src/widgets/ot_drawer.eliom @@ -1,3 +1,5 @@ +open Eio.Std + [%%shared (* Ocsigen * http://www.ocsigen.org @@ -113,11 +115,11 @@ let%shared D.div ~a:(a_class ("ot-drawer-bckgrnd" :: bckgrnd_init_class) :: a) [d] in let bind_touch : - ((unit -> unit) Lwt.t * (unit -> unit) Lwt.u) Eliom_client_value.t + ((unit -> unit) Promise.t * (unit -> unit) Lwt.u) Eliom_client_value.t = [%client Lwt.wait ()] in - let touch_thread = [%client (ref Lwt.return_unit : unit Lwt.t ref)] in + let touch_thread = [%client (ref Lwt.return_unit : unit Promise.t ref)] in let reset_scroll_pos = [%client (fun () -> @@ -179,7 +181,7 @@ let%shared html_ManipClass_remove "ot-drawer-open"; html_ManipClass_remove "ot-drawer-closing"); Lwt.return_unit - : unit Lwt.t)] + : unit Promise.t)] in let _ = [%client diff --git a/src/widgets/ot_picture_uploader.eliom b/src/widgets/ot_picture_uploader.eliom index 9d31d45d..5527d6d3 100644 --- a/src/widgets/ot_picture_uploader.eliom +++ b/src/widgets/ot_picture_uploader.eliom @@ -446,10 +446,7 @@ let%client bind_input input preview ?container ?reset () = type cropping = (float * float * float * float) React.S.t type 'a upload = - ?progress:(int -> int -> unit) - -> ?cropping:cropping - -> File.file Js.t - -> 'a Lwt.t] + ?progress:(int -> int -> unit) -> ?cropping:cropping -> File.file Js.t -> 'a] let%client ocaml_service_upload ~service ~arg ?progress ?cropping file = Eliom_client.call_ocaml_service ~service () ?upload_progress:progress @@ -499,7 +496,7 @@ let%server mk_service name arg_deriver = let%shared mk_form - ?(after_submit = fun () -> Lwt.return_unit) + ?(after_submit = fun () -> ()) ?crop ?input:(input_a, input_content = [], []) ?submit:(submit_a, submit_content = [], []) @@ -532,4 +529,4 @@ let%shared ~upload:~%upload ~after_submit:~%after_submit () : unit)] in - Lwt.return form + form diff --git a/src/widgets/ot_picture_uploader.eliomi b/src/widgets/ot_picture_uploader.eliomi index df129b10..a3c0a3c7 100644 --- a/src/widgets/ot_picture_uploader.eliomi +++ b/src/widgets/ot_picture_uploader.eliomi @@ -33,10 +33,7 @@ open Js_of_ocaml type cropping = (float * float * float * float) React.S.t type 'a upload = - ?progress:(int -> int -> unit) - -> ?cropping:cropping - -> File.file Js.t - -> 'a Lwt.t + ?progress:(int -> int -> unit) -> ?cropping:cropping -> File.file Js.t -> 'a type ('a, 'b) service = ( unit @@ -142,7 +139,7 @@ val submit : (** Create a button with [ot-pup-sumit] clas *) val mk_form : - ?after_submit:(unit -> unit Lwt.t) + ?after_submit:(unit -> unit) -> ?crop:float option -> ?input: [< Html_types.label_attrib > `Class] Eliom_content.Html.attrib list @@ -151,7 +148,7 @@ val mk_form : [< Html_types.button_attrib > `Class] Eliom_content.Html.attrib list * [< Html_types.button_content_fun] Eliom_content.Html.elt list -> 'a upload - -> [> `Form] Eliom_content.Html.elt Lwt.t + -> [> `Form] Eliom_content.Html.elt (** Ready-to-use form. Customizable with [input], the input button content, [submit], the submit button content. If [crop] is present, cropping is enable, with the optional ratio it is. diff --git a/src/widgets/ot_pulltorefresh.eliom b/src/widgets/ot_pulltorefresh.eliom index 23aaf803..16389ac9 100644 --- a/src/widgets/ot_pulltorefresh.eliom +++ b/src/widgets/ot_pulltorefresh.eliom @@ -175,7 +175,7 @@ let make ?(refresh_timeout = 20.) ?(header = [%shared default_header]) ~content - (afterPull : (unit -> bool Lwt.t) Eliom_client_value.t) + (afterPull : (unit -> bool) Eliom_client_value.t) = if app_only && not (Eliom_client.is_client_app ()) then div ~a [content] diff --git a/src/widgets/ot_pulltorefresh.eliomi b/src/widgets/ot_pulltorefresh.eliomi index c45d0054..fb64e4bf 100644 --- a/src/widgets/ot_pulltorefresh.eliomi +++ b/src/widgets/ot_pulltorefresh.eliomi @@ -25,7 +25,7 @@ val make : list) Eliom_shared.Value.t -> content:'a Eliom_content.Html.elt - -> (unit -> bool Lwt.t) Eliom_client_value.t + -> (unit -> bool) Eliom_client_value.t -> 'a Eliom_content.Html.elt (** Creates a pull-to-refresh container from an html element. diff --git a/src/widgets/ot_spinner.eliom b/src/widgets/ot_spinner.eliom index 6a13f3fc..a58d423c 100644 --- a/src/widgets/ot_spinner.eliom +++ b/src/widgets/ot_spinner.eliom @@ -22,7 +22,7 @@ open%client Js_of_ocaml [%%shared open Eliom_content.Html] -[%%shared open Lwt.Syntax] +[%%shared] [%%shared open Eliom_content.Html.F] [%%client open Eliom_shared] @@ -58,20 +58,19 @@ let%server with_spinner ?(a = []) ?spinner:_ ?fail thread = let a = (a :> Html_types.div_attrib attrib list) in let fail = ((match fail with - | Some fail -> (fail :> exn -> Html_types.div_content elt list Lwt.t) - | None -> fun e -> Lwt.return (default_fail e)) - :> exn -> Html_types.div_content elt list Lwt.t) + | Some fail -> (fail :> exn -> Html_types.div_content elt list) + | None -> fun e -> default_fail e) + :> exn -> Html_types.div_content elt list) in - let* v = - Lwt.catch - (fun () -> - let* v = thread in - Lwt.return (v :> Html_types.div_content_fun F.elt list)) - (fun e -> - let* v = fail e in - Lwt.return (v :> Html_types.div_content_fun F.elt list)) + let v = + try + let v = thread in + (v :> Html_types.div_content_fun F.elt list) + with e -> + let v = fail e in + (v :> Html_types.div_content_fun F.elt list) in - Lwt.return (D.div ~a:(a_class ["ot-spinner"] :: a) v) + D.div ~a:(a_class ["ot-spinner"] :: a) v [%%client let num_active_spinners, set_num_active_spinners = React.S.create 0 diff --git a/src/widgets/ot_spinner.eliomi b/src/widgets/ot_spinner.eliomi index c8fb10da..861b5fcd 100644 --- a/src/widgets/ot_spinner.eliomi +++ b/src/widgets/ot_spinner.eliomi @@ -1,3 +1,5 @@ +open Eio.Std + (* Ocsigen Toolkit * http://www.ocsigen.org/ocsigen-toolkit * @@ -26,9 +28,9 @@ val with_spinner : ?a:[< Html_types.div_attrib] Eliom_content.Html.attrib list -> ?spinner:[< Html_types.div_content] Eliom_content.Html.elt list - -> ?fail:(exn -> [< Html_types.div_content] Eliom_content.Html.elt list Lwt.t) - -> [< Html_types.div_content] Eliom_content.Html.elt list Lwt.t - -> [> `Div] Eliom_content.Html.elt Lwt.t + -> ?fail:(exn -> [< Html_types.div_content] Eliom_content.Html.elt list) + -> [< Html_types.div_content] Eliom_content.Html.elt list Promise.t + -> [> `Div] Eliom_content.Html.elt (** On client side, [with_spinner th] returns immediately a spinner while Lwt thread [th] is not finished, that will automatically be replaced by the result of [th] when finished. diff --git a/src/widgets/ot_time_picker.eliom b/src/widgets/ot_time_picker.eliom index a7f3f25f..151595db 100644 --- a/src/widgets/ot_time_picker.eliom +++ b/src/widgets/ot_time_picker.eliom @@ -381,7 +381,7 @@ let display_hours_minutes_seq ?h24 f = Eliom_shared.React.S.l2 [%shared display_hours_minutes_seq ?h24:~%h24 ~%f] let show_minutes_aux - ?(action : (int * int -> unit Lwt.t) Eliom_client_value.t option) + ?(action : (int * int -> unit) Eliom_client_value.t option) e_m hm f_e_m @@ -407,7 +407,7 @@ let get_angle_signal ?round = | _, _ -> e] let make_hours_minutes_seq_24h - ?(action : (int * int -> unit Lwt.t) Eliom_client_value.t option) + ?(action : (int * int -> unit) Eliom_client_value.t option) ?(init = 0, 0) ?(update : (int * int) React.E.t Eliom_client_value.t option) ?round_5 diff --git a/src/widgets/ot_time_picker.eliomi b/src/widgets/ot_time_picker.eliomi index 09c56569..f7bfb804 100644 --- a/src/widgets/ot_time_picker.eliomi +++ b/src/widgets/ot_time_picker.eliomi @@ -23,7 +23,7 @@ (** This module implements a clock-style time picker. *) val make : - ?action:(int * int -> unit Lwt.t) Eliom_client_value.t + ?action:(int * int -> unit) Eliom_client_value.t -> ?init:int * int -> ?update:(int * int) React.E.t Eliom_client_value.t -> ?round_5:bool @@ -56,7 +56,7 @@ val make : is a function that can be called to go back to hours selection. *) val make_hours_minutes_seq : - ?action:(int * int -> unit Lwt.t) Eliom_client_value.t + ?action:(int * int -> unit) Eliom_client_value.t -> ?init:int * int -> ?update:(int * int) React.E.t Eliom_client_value.t -> ?round_5:bool