3 ms·
Disclaimer: I am the author of this library [1]. A few days ago, I ported ocaml/Event [2] to JavaScript, which provides concurrent ML-style synchronization ope
by nirisix 4y ago
Disclaimer: I am the author of this library [1].
A few days ago, I ported ocaml/Event [2] to JavaScript, which provides concurrent ML-style synchronization operations.
It is possible to implement `Channel` and `select` in JS, but it is not easy to provide an idiomatic API and integrate it with the Promise ecosystem.
[1]: https://github.com/dhcmrlchtdj/sync-op https://github.com/dhcmrlchtdj/sync-op
[2]: https://ocaml.org/api/Event.html https://ocaml.org/api/Event.html
- filearts 4y agoI took a stab at this a while back using an object to represent the possible resolutions. The keys of the object become a signal upon resolution that indicates which branch fired. https://github.com/ggoodman/channels#select-key-string-channel--iterablepromise-key-string-value-unknown- https://github.com/ggoodman/channels#select-key-string-chann... Ultimately though, I don't believe that channels are an abstraction that makes sense in JavaScript's concurrency model. Go's contexts, on the other hand, would be a huge improvement over AbortController and AbortSignal.