How to limit the recording frequency on the core.async channel?

Is there an easy way to limit the recording rate to core.async? So far, I could find two examples. One uses a sliding buffer and some SetTimeout magic to handle this, the other uses an external atom as a counter. I was expecting core.async to provide such functionality out of the box. Since one of the examples is pretty old (10 months), I would like to know if theres maybe a simpler solution?

I am looking for a solution that works with Clojure and ClojureScript.

+7
clojure clojurescript
source share
1 answer

throttler lib provides functions for superimposing speed controllers on Clojure (including chokes on channels or functions).

From the readme file:

(def in (chan 1)) (def slow-chan (throttle-chan in 1 :millisecond)) ; 1 msg/ms (>!! in :token) ; => true (<!! slow-chan) ; :token 
+2
source share

All Articles