There is a function chan to create a channel. But I don't see a chan?.
How would I write a predicate chan? that returns true for objects created by chan?
I'm asking about both Clojure and ClojureScript.
Since channels are implemented as:
(deftype ManyToManyChannel [^LinkedList takes ^LinkedList puts ^Queue buf closed ^Lock mutex add!]
...)
You can just check if it's an instance of ManyToManyChannel:
(import [clojure.core.async.impl.channels ManyToManyChannel])
(instance? ManyToManyChannel obj)
Or, if you care more about the protocols rather than the type itself, you can check if the object satisfies? one the the protocols:
(satisfies? clojure.core.async.impl.protocols/WritePort
obj)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With