import { Memento, MementoObject } from './memento.js';
import { IThemeService, Themable } from '../../platform/theme/common/themeService.js';
import { IStorageService, IStorageValueChangeEvent, StorageScope, StorageTarget } from '../../platform/storage/common/storage.js';
import { DisposableStore } from '../../base/common/lifecycle.js';
import { Event } from '../../base/common/event.js';
export class Component extends Themable {
private readonly memento: Memento;
constructor(
private readonly id: string,
themeService: IThemeService,
storageService: IStorageService
) {
super(themeService);
this.memento = new Memento(this.id, storageService);
this._register(storageService.onWillSaveState(() => {
this.saveState();
this.memento.saveMemento();
}));
}
getId(): string {
return this.id;
}
protected getMemento(scope: StorageScope, target: StorageTarget): MementoObject {
return this.memento.getMemento(scope, target);
}
protected reloadMemento(scope: StorageScope): void {
return this.memento.reloadMemento(scope);
}
protected onDidChangeMementoValue(scope: StorageScope, disposables: DisposableStore): Event<IStorageValueChangeEvent> {
return this.memento.onDidChangeValue(scope, disposables);
}
protected saveState(): void {
}
}