@promises/wait
Wait is package from Promises library
Use
Module
$ npm install --save @promises/wait
import {
default as wait
} from '@promises/wait';
Browser
<script src="https://unpkg.com/@promises/wait/bundle.umd.min.js"></script>
let {
wait
} = P;
Examples
let promise: Promise<string> = Promise.resolve<string>('foo');
let count: number = 0;
wait(promise, () => count++ === 3, 1000).then((result: string) => {
console.log(result); // result => 'foo'
});
Functional programming
Module
$ npm install --save @promises/wait
import {
__,
default as wait
} from '@promises/wait/fp';
Browser
<script src="https://unpkg.com/@promises/wait/fp/bundle.umd.min.js"></script>
let {
__,
wait
} = PF;
Examples
let promise: Promise<string> = Promise.resolve<string>('foo');
let count: number = 0;
wait(() => count++ === 3, 1000).then((result: string) => {
console.log(result); // result => 'foo'
})(100)(promise);
Wrapper
Module
$ npm install --save @promises/wait
import Promises from '@promises/core';
import '@promises/wait/add';
Or
import Promises from '@promises/wait/add';
Browser
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/wait/add/bundle.umd.min.js"></script>
let {
Promises
} = P;
Examples
let promises: Promises<string> = Promises.resolve<string>('foo');
let count: number = 0;
promises.wait(() => count++ === 3, 1000).then((result: string) => {
console.log(result); // result => 'foo'
});
Compatibility
These modules are written in typescript and available in ES5 and ES6 standard, the requirements are a global Promise (native or polyfill).
License
Copyright © 2017 Yisrael Eliav, Licensed under the MIT license.