Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Dec 12, 2018
1 parent 95c6b40 commit ebc372d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions js/workers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as dispatch from "./dispatch";
import * as msg from "gen/msg_generated";
import * as flatbuffers from "./flatbuffers";
import { window } from "./globals";
import { libdeno } from "./libdeno";
import { assert, log, setLogDebug } from "./util";
import { globalEval } from "./global_eval";

export async function postMessage(data: Uint8Array): Promise<void> {
const builder = flatbuffers.createBuilder();
Expand Down Expand Up @@ -56,14 +56,18 @@ export async function workerMain() {
setLogDebug(true);
log("workerMain");

// TODO avoid using globalEval to get Window. But circular imports if getting
// it from globals.ts
const window = globalEval("this");

while (!isClosing) {
let data = await getMessage();
const data = await getMessage();
if (data == null) {
log("workerMain got null message. quitting.");
break;
}
if (window["onmessage"]) {
let event = { data };
const event = { data };
window.onmessage(event);
} else {
break;
Expand Down

0 comments on commit ebc372d

Please sign in to comment.