Wasm32/webgl: callback vs mpsc

#1
  1. I am using Rust/wasm32 to write a WebGL application (so frameworks, like Yew, are unlikely to be the right choice.)

  2. One issue I am running into is callbacks vs mpsc. Standard “pureJS” is known for “callback hell”. My current Rust code is callback oriented, but I am considering switchign to mpsc / queue based.

  3. Advice / thoughts from those who have dealt with this issue before?

0 Likes

#2

(Note not something I have explicitly done.)
It is probably best to limit code stack to;
Event-loop->JS->Rust->JS(basics)

For anything without event you could use postMessage and related functions. You then trade potential errors callbacks tend to have for potential asynchronous errors.

0 Likes