-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy path9-timer.js
More file actions
39 lines (31 loc) · 767 Bytes
/
9-timer.js
File metadata and controls
39 lines (31 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Illustrates a personalized message coupled with a timer
*
*/
const xapi = require('xapi');
function update(value) {
//
// Custom logic
//
console.log(value);
}
let current = {};
current.options = [];
current.iterations = 0;
current.iterate = function (original, max) {
// Reset options if array is empty
if (this.options.length === 0) {
this.options = original;
}
this.iterations++;
if (this.iterations > max) {
clearInterval(current.timer);
return;
}
// Pop next option
let choice = this.options.pop();
update(choice)
}
current.timer = setInterval(function () {
current.iterate(["Read a tutorial", "Launch a Sandbox", "Attend an event", "Pick a DevNet activity among:"], 10);
}, 1000);