ex.promise

1.0.0 • Public • Published

Ex.Promise

Promise with the ability to kill it

Install

npm install --save ex.promise

Methods

.init([callback(resolve, reject)]) - standard function for promise

.kill([callback()]) - not required - function for clear all promise dependency

Usage

const ExPromise = require("../index");

const exPromise = new ExPromise();

let interval = null;
const promise = exPromise.init((resolve, reject) => {
  let i = 0;
  interval = setInterval(() => {
    console.log(i++);
  }, 1000);
});

promise
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log(err.message);
  });

setTimeout(() => {
  exPromise.kill(() => {
    //clear all dependency
    clearInterval(interval);
  });
}, 3000);

License

Copyright (c) 2018 Alex Loi Licensed under the MIT license.

Package Sidebar

Install

npm i ex.promise

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

2.28 kB

Total Files

4

Last publish

Collaborators

  • ewardev