Highlighting now works with the web worker

This commit is contained in:
n1474335 2017-09-19 23:34:03 +01:00
parent 8c960f0661
commit 13f07abb8a
10 changed files with 200 additions and 95 deletions

View file

@ -57,6 +57,9 @@ WorkerWaiter.prototype.handleChefMessage = function(e) {
case "statusMessage":
this.manager.output.setStatusMsg(e.data.data);
break;
case "highlightsCalculated":
this.manager.highlighter.displayHighlights(e.data.data.pos, e.data.data.direction);
break;
default:
console.error("Unrecognised message from ChefWorker", e);
break;
@ -150,4 +153,25 @@ WorkerWaiter.prototype.silentBake = function(recipeConfig) {
};
/**
* Asks the ChefWorker to calculate highlight offsets if possible.
*
* @param {Object[]} recipeConfig
* @param {string} direction
* @param {Object} pos - The position object for the highlight.
* @param {number} pos.start - The start offset.
* @param {number} pos.end - The end offset.
*/
WorkerWaiter.prototype.highlight = function(recipeConfig, direction, pos) {
this.chefWorker.postMessage({
action: "highlight",
data: {
recipeConfig: recipeConfig,
direction: direction,
pos: pos
}
});
};
export default WorkerWaiter;