How to directly read and set values between JS and Rust with WASM?

In JS I'm changing two values, let's say x and y. I will send these values to Rust. Right now I'm given them as parameters to an imported Rust function (from WASM in JS). When I change x and y, I will need to call the function again to give Rust these values.

Is there a way for Rust and JS to access the WASM memory directly, so I change x and y in JS and Rust can easily acces and read/use them 'instantly'?

Most importantly, how do I implement this "with wasm-pack (build --target web)"? I can't seem to setup a stream like this: Using the WebAssembly JavaScript API - WebAssembly | MDN since wasm-pack makes a JS file itself with some JS glue code to use.

So, I don't know how to acces the wasm linear memory? in JS and Rust.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.