tabby/app/src/services/config.ts
Eugene Pankov 2acc4f77d4 .
2016-12-30 23:37:41 +03:00

41 lines
729 B
TypeScript

import { Injectable } from '@angular/core'
const Config = nodeRequire('electron-config')
@Injectable()
export class ConfigService {
constructor() {
this.config = new Config({name: 'config'})
this.load()
}
private config: any
private store: any
set(key: string, value: any) {
this.store.set(key, value)
this.save()
}
get(key: string): any {
return this.store[key]
}
has(key: string): boolean {
return this.store[key] != undefined
}
delete(key: string) {
delete this.store[key]
this.save()
}
load() {
this.store = this.config.store
}
save() {
this.config.store = this.store
}
}