1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00
vimr/VimR/PrefService.swift

44 lines
909 B
Swift
Raw Normal View History

2017-02-28 20:53:49 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import Swifter
import RxSwift
fileprivate let defaults = UserDefaults.standard
class PrefService {
2017-02-28 20:53:49 +03:00
2017-03-29 22:36:12 +03:00
static let compatibleVersion = "168"
2017-03-11 19:00:55 +03:00
static let lastCompatibleVersion = "128"
2017-03-01 18:59:23 +03:00
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)
2017-02-28 20:53:49 +03:00
}
}
class PrefPaneService: StateService {
2017-02-28 20:53:49 +03:00
typealias StateType = AppState
func apply(_ state: StateType) {
defaults.setValue(state.dict(), forKey: PrefService.compatibleVersion)
}
2017-02-28 20:53:49 +03:00
}
}