brunoV / throttler

Control the throughput of function calls and core.async channels
286 stars 27 forks source link

Port to cljx so it will work in Clojure and ClojureScript. #2

Open lgastako opened 10 years ago

lgastako commented 10 years ago

As I noted on HN, this still needs a little bit of work to work in both -- specifically the <!! and >!! functions are not available in ClojureScript, but I hope it might still be of value in providing an example of how to set up your project to support both Clojure and ClojureScript at the same time.

brunoV commented 10 years ago

This is great, thanks @lgastako. I have a few dumb questions:

1) I noticed that, while building the project with your fork, a few cljs-specific dependencies (such as the Google Closure compiler) were brought in. This also happened when I compiled an uberjar for a project that depends on this one. Ideally, I'd love it if this didn't happen for server-side projects. Do you know if this is possible? I'm checking out the cljx docs but maybe you know.

2) Yeah, it's unfortunate about <!! and >!!... Do you have any ideas? The way it's used in the function throttler is: before executing the function we take from a throttled channel blockingly. In the server, it's important that the caller's thread is blocked. In the browser it may be enough to instead use take!, where the fn to pass in would be the user function.

Olical commented 8 years ago

Worth looking into this again with cljc now? https://github.com/clojure/clojurescript/wiki/Using-cljc

I'm no expert with Clojure, but maybe it'd be a good thing to contribute if you don't think it'd be too difficult.

I have a CLI project I'm building for work that I would quite like to compile to CLJS instead since the rest of my team are apprehensive of the JVM.