Skip to content

Simple promise library with usage demonstration and steps to reach final version

Notifications You must be signed in to change notification settings

bkbooth/promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Promise library with demo

This repository is a companion to a blog post that I wrote about implementing a Promise library. It contains the final source code for the library, a demonstration page, and branches to demonstrate the different steps of getting to the final solution.

Final library implementation

You can see the finished library code here: promise.js

Demonstration

The demonstration is in index.html, you'll need to clone this repository and then host using something like python2's SimpleHTTPServer module (eg. python -m SimpleHTTPServer) or python3's http.server module (eg. python3 -m http.server). It needs to be hosted for Cross-Origin Resource Sharing (CORS) to request an external image from lorempixel.com

Step branches

Look at the branches named step# for the progression of getting to the final solution:

  • step0: Initial setup of demo, Promise library is empty stub
  • step1: Initial implementation, Promise library handles single .then() with success/failure handlers
  • step2: Promise library can handle chaining .then(), adds .catch() convenience method
  • step3: Promise library can handle .then() handlers returning Promises
  • step4: Implement Promise.race() to resolve/reject with the first of a set of Promises to resolve/reject
  • step5: Implement Promise.all() to resolve a set of Promises at the same time

About

Simple promise library with usage demonstration and steps to reach final version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published