Module Web_worker.Simulate

Simulate the behaviour of a webworker in the main thread.

type t

Type of the simulator of the webworker.

val start : 'rcv Base.Decode.t -> ('rcv -> unit) -> 'msg Base.Decode.t -> 'msg worker_function -> t

start decode callback dec wfun Create and start a simulator of the webworker whose behaviour is described by the pair (dec, wfun).

val post_message : Base.Value.t -> t -> unit

post_message msg w Send the message msg to the webworker simulator w.

val terminate : t -> unit

terminate w Terminate the webworker simulator w.