export default function(self) { let ai_wrapper = new AIWrapper(); self.addEventListener("message", async (event) => { console.log(event.data); switch(event.data.event) { case "setup": await ai_wrapper.setup(event.data.setup_info); self.postMessage({ "event": "setup-complete" }); break; case "predict-row": let message = await ai_wrapper.predict_row(event.data.latitude); message.event = "result"; self.postMessage(message); break; case "end": self.close(); break; } }); }