▲ 19 r/rustgame+2 crossposts

tokio_with_wasm – write async Rust once, run it natively AND in the browser (spawn_blocking included)

If you've ever tried to take an async Rust codebase to the web, you know the pain: tokio just doesn't work on wasm32-unknown-unknown. No threads, no timers, no runtime. You end up littering your code with #[cfg(target_arch = "wasm32")] and rewriting half your task logic around wasm-bindgen-futures.

We built tokio_with_wasm to fix this with one line:

use tokio_with_wasm::alias as tokio; // THIS LINE
use std::time::Duration;

let async_handle = tokio::task::spawn(async { fetch_data().await });
let blocking_handle = tokio::task::spawn_blocking(|| heavy_work());
tokio::time::sleep(Duration::from_secs(1)).await;

That's it. On native targets it resolves to real tokio. On the web, it swaps in a drop-in mimic built on JavaScript web APIs — same module names, same patterns, same code.

Highlights:

  • spawn_blocking() actually works in the browser. It runs your blocking/compute-heavy code in a pool of Web Workers, and the pool auto-scales with the number of parallel tasks. Real parallelism, in a browser tab, from unmodified tokio-style code.
  • spawn**,** yield_now**,** sleep**,** interval**,** JoinSet — the familiar surface is there. Async tasks ride the JS event loop instead of a custom runtime, so nothing fights the browser.
  • We see this as a bridge, not a forever solution: once wasm32-wasi + wasi-threads mature, you shouldn't need it. Until then, this is how you ship.

It's MIT licensed, and there's a demo GIF in the README showing async + blocking tasks running side by side in a browser.

Repo: https://github.com/cunarist/tokio-with-wasm

Fair warning: spawn_blocking on the web needs nightly + atomics target features + COOP/COEP headers for SharedArrayBuffer, and you should avoid panics (no unwinding on wasm32-unknown-unknown). Small price for writing your async code exactly once.

u/Cunarist — 5 days ago
▲ 1 r/appdev

Keeping AI coding agent context in the repo instead of on one dev's machine

App projects accumulate decisions that never make it into code: why the state

management got swapped, which build flavor talks to staging, what the release

checklist actually is. Agents pick that up over a session and then lose it. The

memory lives on one machine in one tool's format, so a new laptop or a

teammate's clone starts from nothing.

`damem` is a small CLI that fixes this by keeping the context in the repository

itself. `.agents/` holds plain Markdown sitting next to the code:

.agents/memory/why-riverpod.md

.agents/skills/release-staging/SKILL.md

.agents/scratch/

One fact per file, each file explains itself, no index to maintain. Whichever

agent the next person uses, it can read this. The tool prints the rules for

keeping that directory and warns when it drifts, but never writes files —

delete the binary and the repo still works.

Setup is one line in AGENTS.md:

> At the start of every session, run `damem recall` and treat its output as

> context for this repository.

MIT, no telemetry: https://github.com/cunarist/damem

How are you handling this on teams? Shared prompt doc, or does everyone just

re-explain the project to their agent every morning?

u/Cunarist — 18 days ago