Skip to Content
Living Clojure
book

Living Clojure

by Carin Meier
April 2015
Beginner
300 pages
4h 59m
English
O'Reilly Media, Inc.
Content preview from Living Clojure

Chapter 6. Communication with core.async

Now that you know how to use libraries, you can get to know a very nice library called core.async, which allows asynchronous and concurrent communication through channels. This allows independent threads of activity to communicate with one another and is an important tool for fast processing and communication. We’ll start exploring how it works with the help of Alice and a sample project.

As Alice continued on her adventure in Wonderland, she happened upon a tea party. It wasn’t just a regular tea party, it was a mad tea party (and by mad I mean crazy). The Mad Hatter, March Hare, and Dormouse were at the table when Alice joined them.

To create a new project, follow these steps:

  1. Run the following command:

    lein new async-tea-party
  2. Go into the new directory that was created:

    cd async-tea-party

Now that you have the project created, you need to modify the project.clj file to include the core.async library. You can go to the GitHub project page for core.async to check for the latest version. It will look something like Figure 6-1.

lvcl 0601
Figure 6-1. GitHub core-async

Edit your project.clj file to include the correct dependency info for the latest core-async library:

(defproject async-tea-party "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Professional Clojure

Professional Clojure

Jeremy Anderson, Michael Gaare, Justin Holguín, Nick Bailey, Timothy Pratley
Clojure Applied

Clojure Applied

Ben Vandgrift, Alex Miller
Clojure Recipes

Clojure Recipes

Julian Gamble
Etudes for ClojureScript

Etudes for ClojureScript

J. David Eisenberg

Publisher Resources

ISBN: 9781491909270Errata Page