open Js_of_ocaml type message = [ | `Complete of Path.Fixed.t | `DeletePoint of (Path.Point.t * Path.Fixed.t) ] let execute (command: [> message]) = match command with | `Complete path -> begin match Path.Fixed.rebuild path with | Some path -> Worker.post_message (`Complete path) | None -> () end | `DeletePoint (point, path) -> begin match Path.Fixed.remove_point path point with | Some path -> Worker.post_message (`Complete path) | None -> () end | any -> Worker.post_message (`Other any) let () = Worker.set_onmessage execute