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
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

Error handling


Back in Chapter 2, A Look at Reactive Extensions, we learned how Reactive Extensions treats errors and exceptions. It provides a rich set of combinators to deal with exceptional cases and are straightforward to use.

Despite being a pleasure to work with, core.async doesn't ship with much support for exception handling. In fact, if we write our code with only the happy path in mind we don't even know an error occurred!

Let's have a look at an example:

(defn get-data []
  (throw (Exception. "Bad things happen!")))

(defn process []
  (let [result (chan)]
    ;; do some processing...
    (go (>! result (get-data)))
    result))

In the preceding snippet, we introduced two functions:

  • get-data simulates a function that fetches data from the network or an in-memory cache. In this case it simply throws an exception.

  • process is a function that depends on get-data to do something interesting and puts the result into a channel, which is returned at the end.

Let's watch what happens when...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Clojure Reactive Programming
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

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

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon