O'Reilly logo

Clojure Applied by Alex Miller, Ben Vandgrift

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting Components with Channels

Components may need to be connected to pass an ongoing series of values, feeding them from a producer component to a consumer component. The core.async channels are ideal for this purpose. When a component needs channels for incoming or outgoing values, the component can either accept external channels or create them internally and make them available.

For example, consider a component that receives a stream of incoming social media messages. One option would be to have the component accept the incoming channel as part of its configuration:

 
(​defn​ make-feed-processor
 
"Create a new Feed Processor on the given input channel."
 
[input-channel] ,,,)

Alternatively, the feed-processor can construct the channel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required