September 2018
Intermediate to advanced
328 pages
9h 10m
English
Create a new file in the /src directory named worker.js and populate it with the following contents:
var wasmInstance = null;self.addEventListener('message', event => { /** * Once the WebAssembly compilation is complete, this posts a message * back with whether or not the instantiation was successful. If the * payload is null, the compilation succeeded. */ const sendCompilationMessage = (error = null) => { self.postMessage({ type: 'COMPILE_WASM_RESPONSE', payload: error }); }; const { type, payload } = event.data; switch (type) { // Instantiates the compiled Wasm module and posts a message back to // the main thread indicating if the instantiation was successful: case 'COMPILE_WASM_REQUEST': const importObj ...Read now
Unlock full access