RoyalIcing / Orb

Write WebAssembly with Elixir
https://useorb.dev
BSD 3-Clause "New" or "Revised" License
174 stars 1 forks source link

Take js object as parameter of a wasm function #9

Open catethos opened 7 months ago

catethos commented 7 months ago

is there a way to write a webassembly function that takes arbitrary javascript object? Rust seem to provide a jsObject type for this purpose

RoyalIcing commented 6 months ago

How would you like to use this with JavaScript? Are you wanting to run it in the browser?

Rust WasmBindgen has an external stack of JavaScript objects, and then an integer index into that stack is passed within WebAssembly. They describe their approach as “shoehorning JS objects into a u32 for wasm to use”. https://rustwasm.github.io/wasm-bindgen/contributing/design/js-objects-in-rust.html

Currently Orb doesn’t generate any helper JavaScript but it may do in the future. If you can describe your use case this can inform that potential effort.

catethos commented 5 months ago

I want to write more Elixir code but my current environment is not supporting it. So I am thinking compiling Elixir code into WASM and run it as some kind of micro service in the server side

RoyalIcing commented 5 months ago

What sort of Elixir code would you want to run — what tasks is it doing?