Precisely!
The DOM and everything related to it should be accessed by a single ‘thread’, messages should be posted to it to alter it in some way, just like you message GenServer’s now.
You could always term_to_binary and vice-versa back or use some other encoding format to marshall data across.
Well you could break up a ‘process’ to carry around and use its own stack, then you have greenthreads, and could keep it on the main thing then.
Honestly I’d say don’t both making receive or threads of any form, javascript is way too different to be able to wrap it in OTP well unless you used emscripten to recompile the BEAM itself to run on the client itself (which you could do).






















