Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fwh1990/promise-listen-catch
https://github.com/fwh1990/promise-listen-catch
Last synced: about 4 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/fwh1990/promise-listen-catch
- Owner: fwh1990
- License: mit
- Created: 2020-09-10T13:51:02.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-12T01:28:54.000Z (about 4 years ago)
- Last Synced: 2024-05-22T21:57:49.068Z (6 months ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Promise Listen Catch
A library to listen the promise chain, and decide to reject or not.# Installation
```bash
yarn add promise-listen-catch
```# Usage
```typescript
import PromiseListenCatch from 'promise-listen-catch';const promise = new PromiseListenCatch((resolve, reject) => {
setTimeout(() => {
if (promise.canReject()) {
reject('throw safely');
} else {
// User doesn't care about result.
// You are recommended to resolve instead of reject.
resolve();
}
});
});promise.then(() => {
// ...
});
```