提交 6c71798d 编写于 作者: B Benjamin Pasero

storage - 💄

上级 b431db5e
......@@ -55,7 +55,7 @@ export class Storage extends Disposable {
this.storage = new SQLiteStorageImpl(options);
this.pendingScheduler = new RunOnceScheduler(() => this.flushPending(), Storage.FLUSH_DELAY);
this.pendingScheduler = this._register(new RunOnceScheduler(() => this.flushPending(), Storage.FLUSH_DELAY));
}
get size(): number {
......@@ -74,7 +74,7 @@ export class Storage extends Disposable {
});
}
get(key: string, fallbackValue?: any): string {
get(key: string, fallbackValue?: string): string {
const value = this.cache.get(key);
if (isUndefinedOrNull(value)) {
......
......@@ -33,6 +33,7 @@ export class StorageService extends Disposable implements IStorageService {
private _onStorageError: Emitter<string | Error> = this._register(new Emitter<string | Error>());
get onStorageError(): Event<string | Error> {
if (Array.isArray(this.bufferedStorageErrors)) {
// todo@ben cleanup after a while
if (this.bufferedStorageErrors.length > 0) {
const bufferedStorageErrors = this.bufferedStorageErrors;
setTimeout(() => {
......@@ -109,7 +110,7 @@ export class StorageService extends Disposable implements IStorageService {
]).then(() => void 0);
}
get(key: string, scope: StorageScope, fallbackValue?: any): string {
get(key: string, scope: StorageScope, fallbackValue?: string): string {
return this.getStorage(scope).get(key, fallbackValue);
}
......@@ -279,7 +280,7 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
return this.storageService as StorageService;
}
get(key: string, scope: StorageScope, fallbackValue?: any): string {
get(key: string, scope: StorageScope, fallbackValue?: string): string {
if (scope === StorageScope.WORKSPACE) {
return this.storageService.get(key, scope, fallbackValue);
}
......
......@@ -46,10 +46,10 @@ suite('StorageService', () => {
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, 'foobar'), 'foobar');
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope, ''), '');
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getInteger', scope, 5), 5);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getInteger', scope, 0), 0);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getBoolean', scope, true), true);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.getBoolean', scope, false), false);
strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, 5), 5);
strictEqual(storage.getInteger('Monaco.IDE.Core.Storage.Test.getInteger', scope, 0), 0);
strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, true), true);
strictEqual(storage.getBoolean('Monaco.IDE.Core.Storage.Test.getBoolean', scope, false), false);
storage.store('Monaco.IDE.Core.Storage.Test.get', 'foobar', scope);
strictEqual(storage.get('Monaco.IDE.Core.Storage.Test.get', scope), 'foobar');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册