-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage-specific-block.ts
45 lines (38 loc) · 1.06 KB
/
stage-specific-block.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
import {MultiStageOutput} from '../src/multi-stage-output.js'
const SLEEP_TIME = Number.parseInt(process.env.SLEEP ?? '100', 10) ?? 100
async function sleep(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}
const ms = new MultiStageOutput<{message: string; staticValue: string; dynamicValue: string}>({
jsonEnabled: false,
stageSpecificBlock: [
{
get: (data) => data?.message,
stage: 'one',
type: 'message',
},
{
get: (data) => data?.staticValue,
label: 'Static',
stage: 'two',
type: 'static-key-value',
},
{
get: (data) => data?.dynamicValue,
label: 'Dynamic',
stage: 'one',
type: 'dynamic-key-value',
},
],
stages: ['one', 'two', 'three'],
title: 'Example',
})
ms.goto('one', {message: 'This is a message', staticValue: 'This is a static key:value pair'})
await sleep(SLEEP_TIME)
ms.goto('two', {dynamicValue: 'This is a dynamic key:value pair'})
await sleep(SLEEP_TIME)
ms.goto('three')
await sleep(SLEEP_TIME)
ms.stop()