jonahwilliams / wasm-call-js-from-rust

Minimal demo calling JavaScript from WebAssembly Rust code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call JS from Rust in WebAssembly

Ever wondered how to do this super simple thing, which should be really easy but for which there is almost no documentation? Wonder no more! In just a few lines of arcane incantations in various languages, it's super easy!

(I kid! Only about 3 of the incantations are arcane!)

Live Demo (Open dev tools to see the console logs.)

Building

Requires Rust Nightly. Only tested on Linux.

make
# or
make debug
# or
make release

(Default is debug.)

Running

cd out/debug  # (or out/release)
python2 -m SimpleHTTPServer

Tutorial (Or: How To Do The Thing)

Really, there's so little code. Just take a look! (It's got comments, even.)

About

Minimal demo calling JavaScript from WebAssembly Rust code


Languages

Language:Rust 42.0%Language:Makefile 24.9%Language:HTML 22.8%Language:JavaScript 10.4%