Re:Go-like channels in 10 lines of JavaScript
by pcattori on Saturday February 04, 2023 @06:10PM
(#34659417)
The main trick on display here is that you can store a reference to the `resolve` method of a promise that normally would have to be called within the promise definition itself.
Of course, you don't need a channel abstraction to do that. To me, channels are the most intuitive and self-contained way to solve the problem, so I wanted to use that model of concurrency in JS.
Of course, you don't need a channel abstraction to do that. To me, channels are the most intuitive and self-contained way to solve the problem, so I wanted to use that model of concurrency in JS.