Promises

If you are a full stack Java developer, there is a good chance that you have met promises in JavaScript.

Promises are simple abstractions that don't impose strict requirements on you; you can use them to calculate the result on some other thread, light process, or anything you like.

In Java, there are a couple of ways to achieve this; one of them is with futures (java.util.concurrentFuture) and if you want something more similar to JavaScript's promise there is a nice implementation called jdeferred (https://github.com/jdeferred/jdeferred), which you might have used before.

In essence a promise is just a promise that you can give to your caller, the caller can use it at any given time. There are two possibilities:

  • If the promise has already ...

Get Clojure: High Performance JVM Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.