Execute when condition fulfill.
- 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;
var c = new Condition(true, false);
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';
var ww = new WaitWhen();
ww.then(c, function() {
console.log('the condition named c fulfilled');
});
ww.then([c1, c2, c3], function() {
console.log('all conditions fullfilled');
});
I use Watch.JS to detect array and object change, lodash/isEqual to compare fulfillValue with value.
If you want to build by yourself.please run
npm run build
If you want to do the test.please run
npm test