-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-1.ts
46 lines (40 loc) · 982 Bytes
/
example-1.ts
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
39
40
41
42
43
44
45
46
import { CountdownSegment, CountupSegment, ITimeEmission, Sequencer } from 'sots';
const sequencer: Sequencer = new Sequencer({ period: 1000 });
sequencer.add(CountdownSegment, {
duration: 3000,
states: [
{ state: 'Started!', timeAt: '3' },
],
})
.add(CountupSegment, {
duration: 3000,
states: [
{ state: 'Halfway', timeAt: '0' },
],
});
sequencer.subscribe((value: ITimeEmission) => {
let output: string;
output = 'time: ' + value.time;
if (value.state) {
if (value.state.valueOf('Started!')) {
output += '<play audible for start>';
} else if (value.state.valueOf('Halfway')) {
output += '<play audible for halfway point>';
}
}
console.log(output);
}, (error) => {
console.error(error);
}, () => {
console.log('<play audible for completed>');
});
sequencer.start();
/*
time: 3<play audible for start>
time: 2
time: 1
time: 0<play audible for halfway point>
time: 1
time: 2
<play audible for completed>
*/