Hacker News new | ask | show | jobs
by nirisix 1237 days ago
You can try the following code snippet on the https://playground.esm.sh/ if you're interested.

```typescript

import { Channel, select } from "https://esm.sh/sync-op";

async function main() {

const c1 = new Channel<string>();

const c2 = new Channel<number>();

const c3 = new Channel<boolean>();

c1.send("hello").sync();

c2.send(1).sync();

c3.send(true).sync();

const r1 = await select(c1.receive(), c2.receive(), c3.receive());

alert(r1.unwrap());

const r2 = await select(c1.receive(), c2.receive(), c3.receive());

alert(r2.unwrap());

}

main();

```