Member-only story
A Tour of Manifold’s Deferred, Stream and Event Bus API
Higher level abstractions for asynchronous things in Clojure
In this piece and I am going to explore the Manifold library to take a look at Manifold’s Deferred, Stream and Event Bus features. This is a really handy tool kit for anyone doing asynchronous programming in Clojure[Script]. We can use deferred values to helps us to manage and abstract away some of the complexity of dealing with values that might arrive asynchronously, streams to connect all sorts of things together and an Event bus to provide a simple event driven messaging architecture.
Towards the end of the article we will also look at how these tools can be combined to perform asynchronous communication between the front and back-end of our app using a web-socket. Although we won’t be going into any topic in particular detail, it might be helpful to get an overview of the library and what it has to offer.
What is Manifold?
Manifold was originally designed by Zach Tellman and it describes itself as a library that provides the basic building blocks for asynchronous programming, which can be used as a translation layer between libraries that use similar but incompatible abstractions.
I like to think of Manifold as offering a slightly higher level of abstraction for our asynchronous programming. We can use it as we would any other asynchronous library. However, the cool part is that it offers far more compatibility and composability than we would have if we were to work with other libraries.

Here is a brief overview of three key parts of the library:
Manifold.deferred
Methods for creating, transforming, and interacting with asynchronous values.Manifold.streams
Manifold’s streams provide mechanisms for asynchronous puts and takes, timeouts, and backpressure. They are compatible with Java’sBlockingQueues
, Clojure's lazy sequences, and core.async's channels. Methods for converting to and from each are provided.Manifold.bus
Manifold also provides a simple event bus that can be used for pub/sub communication.
You can download the library here: