Comment

Comment by _benton

You can also schedule code to run each "tick" of the event loop, which is a non-blocking version of a while loop.

Or you could promisify the send function and use normal async/await.

   let q = Promise.resolve(),
     sendAsync = (p) => new Promise(r => send(p, r)),
     sendOnce = (p, c, ms) => setTimeout(_ => q.then(_ => sendAsync(p)).then(c), ms)
Or you could actually spin up a new worker thread and get multithreading :P
parent _benton 1 year ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton