1.0.0 • Published 6 years ago

ex.promise v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

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.