From 329b774e315b41bc0d5b7daf8737222768c8d1f3 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 9 Jan 2021 11:35:40 +0100 Subject: Formalized exchanges between worker and app --- script.it/worker.ml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'script.it/worker.ml') diff --git a/script.it/worker.ml b/script.it/worker.ml index 4ea9220..00e4595 100755 --- a/script.it/worker.ml +++ b/script.it/worker.ml @@ -1,11 +1,10 @@ open Js_of_ocaml -type message = [ - | `Complete of Path.Fixed.t - | `DeletePoint of (Path.Point.t * Path.Fixed.t) -] +let post_message + : Worker_messages.from_worker -> unit + = Worker.post_message -let execute (command: [> message]) = +let execute (command: [> Worker_messages.to_worker]) = match command with | `Complete path -> begin match Path.Fixed.rebuild path with @@ -17,8 +16,8 @@ let execute (command: [> message]) = | Some path -> Worker.post_message (`Complete path) | None -> () end - | any -> - Worker.post_message (`Other any) + | _ -> + post_message (`Other (Js.string "Unknown message received")) let () = Worker.set_onmessage execute -- cgit v1.2.3