Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/willybrauner/deferred-promise

🙏🏽 Create a deferred promise who can be resolved or rejected from anywhere.
https://github.com/willybrauner/deferred-promise

javascript lib library promise typescript

Last synced: 8 days ago
JSON representation

🙏🏽 Create a deferred promise who can be resolved or rejected from anywhere.

Awesome Lists containing this project

README

        

# @wbe/deferred-promise

Create a deferred promise who can be resolved or rejected from anywhere.

![](https://img.shields.io/npm/v/@wbe/deferred-promise/latest.svg)
![](https://img.shields.io/bundlephobia/minzip/@wbe/deferred-promise.svg)
![](https://img.shields.io/npm/dt/@wbe/deferred-promise.svg)
![](https://img.shields.io/npm/l/@wbe/deferred-promise.svg)

## Installation

```shell script
$ npm install -s @wbe/deferred-promise
```

## How to use

```js
import { deferredPromise } from "@wbe/deferred-promise";

// create deferred promise
const deferred = deferredPromise();

deferred.promise.then(() => {
// deferredPromise is resolved!
});

// when needed, resolve this promise
deferred.resolve();

// or reject it
deferred.reject();
```