September 2018
Intermediate to advanced
328 pages
9h 10m
English
You should have two compiled Wasm files in the /src/assets folder of your project: main.wasm and memory.wasm. Since we need to utilize the malloc() and free() functions exported from memory.wasm in the main.wasm code, our loading code is going to look different from the earlier examples. Create a file in the /src/store folder named initializeWasm.js and populate it with the following contents:
/** * Returns an array of compiled (not instantiated!) Wasm modules. * We need the main.wasm file we created, as well as the memory.wasm file * that allows us to use C functions like malloc() and free(). */const fetchAndCompileModules = () => Promise.all( ['../assets/main.wasm', '../assets/memory.wasm'].map(fileName ...
Read now
Unlock full access