Promises as Values

I was recently working on a small JavaScript project in which I needed to perform several asynchronous operations sequentially. I had a collection of images on a page and I needed to fade each of them out one at a time. I ended up with a nice technique using Promises. Let’s suppose we have a function that fades out an image given a selector and a duration (I was using jQuery, but the details don’t matter). We can call this function like so: ...

July 13, 2017 · Drew Olson

Another Perspective on Promises

I spent 9 months of this year working on a project using Java 8 and enjoyed it much more than I expected. Specifically, the addition of Optional made my code feel cleaner, more functional and less error prone. I had Java 8 on the brain when I tackled a small JavaScript project a few weeks ago. After finishing it, I decided to go back and try it again using Promises. I was immediately struck by how similar Promises are to a cousin of the Optional – Result. In this post I’ll describe Promises from the perspective of building robust pipelines for your code, later showing how Promises also unify synchronous and asynchronous code. ...

December 28, 2016 · Drew Olson