aboutsummaryrefslogtreecommitdiff
path: root/script.it/worker.ml
blob: 00e4595d7ed868cd5a971ef7b65a3f9142b99f10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
open Js_of_ocaml

let post_message
  : Worker_messages.from_worker -> unit
  = Worker.post_message

let execute (command: [> Worker_messages.to_worker]) =
  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
  | _ ->
    post_message (`Other (Js.string "Unknown message received"))

let () =
  Worker.set_onmessage execute