Skip to content

Deferred promise implementation for those times when you do actually need it which is not that rare

Notifications You must be signed in to change notification settings

TomasHubelbauer/js-deferred

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

JavaScript Deferred Promise

A copy-paste friendly implementation of the deferred promise pattern ready for you to use, because this pattern is useful no matter what others may tell you.

export default class Deferred extends Promise {
  constructor() {
    let _resolve;
    let _reject;
    super((resolve, reject) => {
      _resolve = resolve;
      _reject = reject;
    });

    this.resolve = _resolve;
    this.reject = _reject;
  }
}

Deferred.prototype.constructor = Promise;

https://stackoverflow.com/a/48159603/2715716

About

Deferred promise implementation for those times when you do actually need it which is not that rare

Topics

Resources

Stars

Watchers

Forks