If sending arraybuffer back, use a transferable object

This commit is contained in:
j433866 2019-04-26 14:01:49 +01:00
parent 7b169fb798
commit f638bd4ded
1 changed files with 17 additions and 8 deletions

View File

@ -101,14 +101,23 @@ async function bake(data) {
data.progress, // The current position in the recipe
data.step // Whether or not to take one step or execute the whole recipe
);
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id,
inputNum: data.inputNum
})
});
if (typeof response.result === "string") {
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id,
inputNum: data.inputNum
})
});
} else {
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id,
inputNum: data.inputNum
})
}, [response.result]);
}
} catch (err) {
self.postMessage({
action: "bakeError",