wait-when

1.0.1 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i wait-when

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

62.2 kB

Total Files

13

Last publish

Collaborators

  • robberfree