Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It'd be doable but getting a nice Clojure-y API over it would take a little more work.

To start, you could try making a 1-to-1 mapping by closing over the web worker methods with cljs functions. To keep track of the web workers, you could put them in a cljs map inside an atom. This is what servant does to handle web workers.[0]

The other interfaces could be handled in a similar way by closing over methods with functions too.

It might be better after brute forcing a basic 1-to-1 style to create one or more layers of abstraction to make the interop more usable and Clojure-y. There could be cljs deftypes for the threads or web workers which hook into core cljs protocols[1] so that cljs.core functions would work over them. Macros could add syntactic sugar to lower level functions to make your API easier to use (looks like servant did that).

There are lots of options for how to build a good API depending on how powerful an abstraction you want to make for yourself. Getting basic support for the library could work by just closing over functions and adding some glue though.

[0]https://github.com/MarcoPolo/servant/blob/master/src/cljs/se...

[1]https://github.com/clojure/clojurescript/blob/master/src/mai...



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: