This file has been truncated. show original
The aim of this project is to gradually implement the Elm language in WebAssembly. But currently Wasm is still in MVP stage and does not have direct access to browser APIs like the DOM, `XmlHttpRequest`, `Date`, and so on. (A few WebAssembly proposals need to get implemented first, such as [GC](https://github.com/WebAssembly/gc/blob/master/proposals/gc/Overview.md#host-types) and [type imports](https://github.com/WebAssembly/proposal-type-imports/blob/master/proposals/type-imports/Overview.md).)
![Diagram. Effectful kernel code on the left. Pure functional WebAssembly module on the right with a wrapper around it to interface to JS. JS calls Wasm for init, update, subscriptions, view. Wasm calls JS to get effects.](./images/JS-Wasm-wrapper.png)
## Working demo
There's a working demo of this setup [here](https://brian-carroll.github.io/elm_c_wasm/wrapper/index.html). It's the simplest app I could think of that shows both `Cmd` and `VirtualDom` effects working! You can also check out the [source code](/demos/wrapper).
## The Wrapper
The "wrapper" shown in the architecture diagram above translates between Wasm and JS data structures, and allows JS and Wasm functions to call each other.