Skip to Main Content
Hands-On Reactive Programming with Clojure - Second Edition
book

Hands-On Reactive Programming with Clojure - Second Edition

by Konrad Szydlo, Leonardo Borges
January 2019
Intermediate to advanced content levelIntermediate to advanced
298 pages
7h 46m
English
Packt Publishing
Content preview from Hands-On Reactive Programming with Clojure - Second Edition

Implementing event streams

The event stream implementation, on the other hand, is the most complex in our framework. We'll tackle it gradually, implementing it and experimenting as we go.

First, let's look at our main constructor function, event-stream:

(defn event-stream 
  "Creates and returns a new event stream. You can optionally provide an existing 
  core.async channel as the source for the new stream" 
  ([] 
     (event-stream (chan))) 
  ([ch] 
     (let [multiple  (mult ch) 
           completed (atom false)] 
       (EventStream. ch multiple completed)))) 

The docstring should be sufficient to understand the public API. What might not be clear, however, is what all the constructor arguments mean. From left to right, the arguments to EventStream are as follows:

  • ch: This is ...
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.
Start your free trial

You might also like

Clojure Programming

Clojure Programming

Chas Emerick, Brian Carper, Christophe Grand
Clojure in Action, Second Edition

Clojure in Action, Second Edition

Amit Rathore, Francis Avila
Programming Clojure, 2nd Edition

Programming Clojure, 2nd Edition

Stuart Halloway, Aaron Bedra

Publisher Resources

ISBN: 9781789346138Supplemental Content