wait-when
v1.0.1
Published
Execute when condition fulfill.
Downloads
3
Readme
wait-when
Execute when condition fulfill.
Usage
- Node
npm i wait-when
const { Condition, WaitWhen } = require('wait-when');
- Browser
<script src="wait-when.min.js"></script>
It has a global variable "ww".
var Condition = ww.Condition;
var WaitWhen = ww.WaitWhen;
API
1. Condition(fulfillValue,value)
var c = new Condition(true, false);
2. Condition.value
Set condition's value.
You can create a new value and assign to it.(Recommended)
For array and object value you can also change it directly.
(Warning:it's not perfect to detect array and object change)
c.value = true;
c.value.push('item');
c.value.key = 'value';
3. WaitWhen
var ww = new WaitWhen();
4. WaitWhen.then(conditions,cb)
ww.then(c, function() {
console.log('the condition named c fulfilled');
});
ww.then([c1, c2, c3], function() {
console.log('all conditions fullfilled');
});
Dependencies
I use Watch.JS to detect array and object change, lodash/isEqual to compare fulfillValue with value.
Build
If you want to build by yourself.please run
npm run build
Test
If you want to do the test.please run
npm test