5 ms·
I'm curious how this works in terms of interoperability with Javascript but I couldn't understand that from reading their website. Does anyone here know how the
by ufo 6y ago
I'm curious how this works in terms of interoperability with Javascript but I couldn't understand that from reading their website. Does anyone here know how the interop works, by any chance?
* Can JS functions call Assemblyscript functions?
* Can AssemblyScript functions call JS functions?
* Can Assemblyscript manipulate Javascript objects? Or is the communication restricted to low-level types such as integers, WASM byte arrays, and so forth?
- maxgraey 6y agoYou're right WebAssembly hasn't provide seamless interop for compound objects. AS expose special utility called loader: https://www.assemblyscript.org/loader.html#usage https://www.assemblyscript.org/loader.html#usage There are also exists other projects which simplify this: https://github.com/torch2424/as-bind https://github.com/torch2424/as-bind
- ufo 6y agoThanks, but the WASM ecosystem is a bit foreign to me so some of what you said went right over my head. Would it be correct to say that: 1. AssemblyScript functions can be exposed to Javascript via the loader utility. If the arguments are primitive types then calling them is straightforward. Complex types like strings and arrays must be converted between the JS version of the type and the AS version of the type. 2. AssemblyScript code cannot call Javascript functions or directly manipulate Javascript objects. However, Javascript objects and functions can be passed around as an opaque anyref.
- deleted 6y ago[deleted]