crystal wasm.cr
php -S localhost:3000
- open your browser
- open dev tool js console
crystal.add(1, 2)
This writes the WASM bytes with the built-in add_function
named add
to a file called crystal.wasm
.
Then a fetch call loads the result in to WebAssembly, and puts that function in to a JS object called crystal
.
You're calling an add function from WASM that was generated using crystal... It's kinda neat, but pretty useless.