aboutsummaryrefslogtreecommitdiff
path: root/script.it/worker.ml
blob: 4ea92204116f7c84148eac5b5486e145b30be8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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