Well then - please ignore my answer too ;-)

Regarding the code, it looks fine to me, though I do not have much
experience with core.async. I would suggest a small change to the args
vector to become [c & [f]], so you can avoid the (first f) call. I would
find it more readable that way.

Also, maybe the docstring could make it clearer that it only drains the
channel temporarily ? Or that it should obly be called after the producers
stopped ? The 700 in there seems pretty arbitrary.

On Wednesday, 17 December 2014, Gary Verhaegen <[email protected]>
wrote:

> I can't help you, but you should probably indicate your core.async version
> too.
>
> I seem to remember some warnings about mixing arbitrary versions of cljs
> and core.async, so if you recently updated cljs and did not change your
> core.async dep, that might be related.
>
> On Wednesday, 17 December 2014, Andrew <[email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:
>
>> I've compiled and used this for a while without problems, a simple
>> utility function to drain all the remaining values on a channel:
>>
>> (defn drain
>>   "Takes all values available on a chan then returns a vector of them,
>> leaving the channel empty. Compatible with cljs too. Optionally takes a
>> single function which accepts a single value and will process each drained
>> value with this function, while also placing original value onto the
>> vector."
>>   [c & f]
>>   (go
>>    (loop [r []]
>>      (alt!
>>       (timeout 700) r
>>       c ([v]
>>            (when f
>>              ((first f) v))
>>            (recur (conj r v)))))))
>>
>> I used this on clojurescript 0.0-2173.  When I upgraded to 0.0-2311 I now
>> get the error: "Can't recur here".
>>
>> Since the code didn't change, why is recur allowed in one version but not
>> the other?
>>
>> --
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ClojureScript" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/clojurescript.
>>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to