forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.ts
More file actions
44 lines (34 loc) · 1.3 KB
/
component.ts
File metadata and controls
44 lines (34 loc) · 1.3 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Memento, MementoObject } from 'vs/workbench/common/memento';
import { IThemeService, Themable } from 'vs/platform/theme/common/themeService';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
export class Component extends Themable {
private readonly memento: Memento;
constructor(
private readonly id: string,
themeService: IThemeService,
storageService: IStorageService
) {
super(themeService);
this.id = id;
this.memento = new Memento(this.id, storageService);
this._register(storageService.onWillSaveState(() => {
// Ask the component to persist state into the memento
this.saveState();
// Then save the memento into storage
this.memento.saveMemento();
}));
}
getId(): string {
return this.id;
}
protected getMemento(scope: StorageScope): MementoObject {
return this.memento.getMemento(scope);
}
protected saveState(): void {
// Subclasses to implement for storing state
}
}