Chapter 5. Creating a WebAssembly module that calls into JavaScript
This chapter covers
- Calling into JavaScript directly using Emscripten’s toolkit
- Calling into JavaScript without Emscripten’s toolkit
In chapter 4, you created a WebAssembly module that your JavaScript code called into using Emscripten’s ccall helper function. You passed a buffer as a parameter to the module’s function so that, if there was an issue, an error message could be returned by placing it into the buffer. If there was an issue, your JavaScript read the string from the module’s memory and then displayed the message to the user, as figure 5.1 shows.
Figure 5.1. How the JavaScript code currently interacts with the module’s functions
Imagine that rather than passing ...
Get WebAssembly in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.