Running the start script

The application has the webpack-dev-server library installed, which operates like Browsersync. The library uses LiveReloading, which automatically updates the application when you make any changes to the files in /src. Since we're using a Webpack loader for C and C++ files, the automatic update event will trigger if you change the C file as well. Run the following the command to start the application and watch for changes:

npm start

A browser window should open automatically when the build completes, and then direct you to the running application. To see the live-reloading feature in action, try setting the value of the isRunning variable in the setIsRunning() function in main.c to false instead of newIsRunning:

EMSCRIPTEN_KEEPALIVE
void setIsRunning(bool newIsRunning) {
// isRunning = newIsRunning;

// Set the value to always false:
isRunning = false;
}

The spaceship should be stuck in the upper-left corner. If you change it back, the spaceship starts moving again. In the next section, we will write unit tests in JavaScript to test WebAssembly modules.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset