Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Clojure Reactive Programming
  • Table Of Contents Toc
  • Feedback & Rating feedback
Clojure Reactive Programming

Clojure Reactive Programming

By : Leonardo Borges
4.3 (13)
close
close
Clojure Reactive Programming

Clojure Reactive Programming

4.3 (13)
By: Leonardo Borges

Overview of this book

If you are a Clojure developer who is interested in using Reactive Programming to build asynchronous and concurrent applications, this book is for you. Knowledge of Clojure and Leiningen is required. Basic understanding of ClojureScript will be helpful for the web chapters, although it is not strictly necessary.
Table of Contents (13 chapters)
close
close
11
B. Bibliography
12
Index

Exercises


The following sections have a few exercises for you.

Exercise 5.1

Extend our current EventStream implementation to include a function called take. It works much like Clojure's core take function for sequences: it will take n items from the underlying event stream after which it will stop emitting items.

A sample interaction, which takes the first five items emitted from the original event stream, is shown here:

(def es1 (from-interval 500))
(def take-es (take es1 5))

(subscribe take-es #(prn "Take values: " %))

;; "Take values: " 0
;; "Take values: " 1
;; "Take values: " 2
;; "Take values: " 3
;; "Take values: " 4

Tip

Keeping some state might be useful here. Atoms can help. Additionally, try to think of a way to dispose of any unwanted subscriptions required by the solution.

Exercise 5.2

In this exercise, we will add a function called zip that zips together items emitted from two different event streams into a vector.

A sample interaction with the zip function is as follows:

(def es1 ...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY