How to manage state on the Rust side when using WASM?

This page summarizes the projects mentioned and recommended in the original post on /r/rust

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • rust

    Empowering everyone to build reliable and efficient software.

  • Which aren't supported by prebuilt std, meaning you'll need a nightly compiler to -Zbuild-std after enabling a compiler flag to enable atomic operations, after which point you can't even use std::thread. The tracking issue hasn't had much progress.

  • Allusion

    A free and open source desktop application for managing your visual library

  • You can only block a web worker thread; blocking in the main thread is not allowed by browser vendors. If you want to synchronize two web workers, you can use the std primitives like Mutex and compile with atomics. If you want to synchronize the main thread and a web worker, you need to build this yourself. I have implemented this in one of my code bases (https://github.com/allusion-app/Allusion/blob/master/wasm/masonry/src/sync.rs) but the code is GPL licensed. Note this particular code only works in browsers that support Atomics.waitAsync. An alternative is to wrap a worker.onmessage callback in a Promise and await that. Also statics are used because I don't want the overhead of calling receive from JavaScript back to Rust in the web worker, not that they are required.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts