Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 3, 2016
1 parent bb658ff commit 0357c71
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/vs/code/electron-main/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@

import * as path from 'path';
import * as fs from 'original-fs';
import { EventEmitter } from 'events';
import { IEnvService } from 'vs/code/electron-main/env';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

const EventTypes = {
STORE: 'store'
};

export const IStorageService = createDecorator<IStorageService>('storageService');

export interface IStorageService {
_serviceBrand: any;
onStore<T>(clb: (key: string, oldValue: T, newValue: T) => void): () => void;
getItem<T>(key: string, defaultValue?: T): T;
setItem(key: string, data: any): void;
removeItem(key: string): void;
Expand All @@ -31,18 +25,11 @@ export class StorageService implements IStorageService {

private dbPath: string;
private database: any = null;
private eventEmitter = new EventEmitter();

constructor(@IEnvService private envService: IEnvService) {
this.dbPath = path.join(envService.appHome, 'storage.json');
}

onStore<T>(clb: (key: string, oldValue: T, newValue: T) => void): () => void {
this.eventEmitter.addListener(EventTypes.STORE, clb);

return () => this.eventEmitter.removeListener(EventTypes.STORE, clb);
}

getItem<T>(key: string, defaultValue?: T): T {
if (!this.database) {
this.database = this.load();
Expand All @@ -68,11 +55,8 @@ export class StorageService implements IStorageService {
}
}

const oldValue = this.database[key];
this.database[key] = data;
this.save();

this.eventEmitter.emit(EventTypes.STORE, key, oldValue, data);
}

removeItem(key: string): void {
Expand All @@ -81,11 +65,8 @@ export class StorageService implements IStorageService {
}

if (this.database[key]) {
const oldValue = this.database[key];
delete this.database[key];
this.save();

this.eventEmitter.emit(EventTypes.STORE, key, oldValue, null);
}
}

Expand Down

0 comments on commit 0357c71

Please sign in to comment.