1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 00:34:26 +03:00
vimr/VimR/PrefService.swift
2017-04-11 18:49:17 +02:00

44 lines
909 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import Swifter
import RxSwift
fileprivate let defaults = UserDefaults.standard
class PrefService {
static let compatibleVersion = "168"
static let lastCompatibleVersion = "128"
let forMainWindow = PrefMainWindowService()
let forPrefPanes = PrefPaneService()
}
extension PrefService {
class PrefMainWindowService: Service {
typealias Pair = StateActionPair<AppState, UuidAction<MainWindow.Action>>
func apply(_ pair: Pair) {
guard case .close = pair.action.payload else {
return
}
defaults.setValue(pair.state.dict(), forKey: PrefService.compatibleVersion)
}
}
class PrefPaneService: StateService {
typealias StateType = AppState
func apply(_ state: StateType) {
defaults.setValue(state.dict(), forKey: PrefService.compatibleVersion)
}
}
}