anticipant

callback executes when completed all the goals

Usage no npm install needed!

<script type="module">
  import anticipant from 'https://cdn.skypack.dev/anticipant';
</script>

README

anticipant

install

npm install anticipant

example

var Anticipant = require('anticipant');

anticipant = Anticipant.create(['task1', 'task2']);
anticipant.register('task3');

anticipant.then(function() {
    console.log('tasks 1, 2 and 3 done!')
});

anticipant.perform('task1');
anticipant.perform('task2');
anticipant.perform('task3');
// in console -> tasks 1, 2 and 3 done!

methods and fields

Anticipant.create(listOfTasks, resultFunction);

returned new anticipant instance.

Anticipant.register(taskName)

register new task, if task already exists reset done flag to false.

Anticipant.perform(taskName)

perform registered task. When all tasks are performed call result function.

Anticipant.then(taskName)

register result function.