package jext
Js_of_ocaml tools to help handling web extension
Install
Dune Dependency
Authors
Maintainers
Sources
jext-0.1.0.tar.gz
md5=fed8296cfc592824344f21fb4185cf29
sha512=b1cbd394782aaa7a24baf1d8f17d0e6076b5fb209f1467123a3a609975a8906ec55de02a1c6ccc5841c7f1fda5ce506004b161242ba16263f19cc44c007b26a4
doc/src/jext.lwt/client_lwt.ml.html
Source file client_lwt.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
open Chrome_lwt open Common.Types module Lib(S: S) = struct include Make(S) let send_req ?id ?(wait_callback=false) req_input = let info = Utils.Runtime.mk_connection_info "client" in let req_id = match id with | None -> Int32.to_int @@ Random.int32 Int32.max_int | Some i -> i in try let req = request_aux_to_jsoo S.request_jsoo_conv {req_id; req_input; req_src=`client} in let port = Runtime.connect ~info () in if wait_callback then let w, n = Lwt.wait () in Utils.Browser.addListener1 port##.onMessage (fun res -> try let res = response_aux_of_jsoo response_jsoo_conv res in match res.res_src with | `background when res.res_id = req_id -> port##disconnect; Lwt.wakeup n (Result.map Option.some res.res_output) | _ -> () with exn -> Lwt.wakeup n (Error (`generic ("wrong response", Printexc.to_string exn)))); port##postMessage req; w else ( port##postMessage req; Lwt.return_ok None) with exn -> Lwt.return_error (`generic ("wrong request", Printexc.to_string exn)) let () = Random.self_init () end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>