Skip to content

Commit f516346

Browse files
committed
fix docs
1 parent c207edd commit f516346

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

addons/addon-progress/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ProgressAddon } from '@xterm/addon-progress';
2020
const terminal = new Terminal();
2121
const progressAddon = new ProgressAddon();
2222
terminal.loadAddon(progressAddon);
23-
progressAddon.register((state: number, value: number) => {
23+
progressAddon.onChange({state, value}: IProgress) => {
2424
// state: 0-4 integer (see below for meaning)
2525
// value: 0-100 integer (percent value)
2626

@@ -69,11 +69,10 @@ The addon resolves most of those semantic nuances and will provide these ready-t
6969
### API
7070

7171
The addon exposes the following API endpoints:
72-
- `public register(handler: ProgressHandler): IDisposable;` \
73-
Registers your actual progress handler, where you gonna do the visual progress visualisation.
74-
The handler will get called upon valid progress sequences with 2 arguments as `(state, value) => {}`.
75-
Returns a disposable to unregister the handler later on by calling its `dispose()` method.
76-
- `public progress: IProgress;`
72+
- `public readonly onChange: IEvent<IProgress>` \
73+
Event to register your actual progress handler, where you gonna do the progress visualisation.
74+
The handler will get called upon valid progress sequences with a progress argument as `({state, value}) => {}`.
75+
- `public progress: IProgress`
7776
A getter/setter for the current progress information. Can be used to read the last seen progress information.
7877
This can also be used to clean up stuck progress indicators by setting the value back to initial, e.g.:
7978
```typescript

demo/client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,13 +1454,12 @@ function progressButtons(): void {
14541454
const STATES = { 0: 'remove', 1: 'set', 2: 'error', 3: 'indeterminate', 4: 'pause' };
14551455
const COLORS = { 0: '', 1: 'green', 2: 'red', 3: '', 4: 'yellow' };
14561456

1457-
function progressHandler(progress: IProgress) {
1458-
let {state, value} = progress;
1457+
function progressHandler({state, value}: IProgress) {
14591458
// Simulate windows taskbar hack by windows terminal:
14601459
// Since the taskbar has no means to indicate error/pause state other than by coloring
14611460
// the current progress, we move 0 to 10% and distribute higher values in the remaining 90 %
1462-
// NOTE: This most likely not what you want to do for other progress indicators,
1463-
// that have a proper visual state for error/paused
1461+
// NOTE: This is most likely not what you want to do for other progress indicators,
1462+
// that have a proper visual state for error/paused.
14641463
value = Math.min(10 + value * 0.9, 100);
14651464
document.getElementById('progress-percent').style.width = `${value}%`;
14661465
document.getElementById('progress-percent').style.backgroundColor = COLORS[state];

0 commit comments

Comments
 (0)