Skip to content

Instantly share code, notes, and snippets.

No one.

Harshit Kaushik HarshitKaushik

No one.
View GitHub Profile
HarshitKaushik /
Created Jun 13, 2018 — forked from domenic/
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
public static String getActivityTime(Date inputDate) {
Date currentDate = new Date();
Long currentTime = new Date().getTime();
Long inputTime = inputDate.getTime();
long timeRemaining = currentTime - inputTime;
long sec = (timeRemaining / 1000) % 60;
long min = (timeRemaining / (1000 * 60)) % 60;
long hours = (timeRemaining / (1000 * 60 * 60)) % 24;
You can’t perform that action at this time.