1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00
vimr/VimR/GeneralPrefTransformer.swift
2017-02-27 22:45:26 +01:00

35 lines
792 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import RxSwift
class GeneralPrefTransformer: Transformer {
typealias Pair = StateActionPair<AppState, GeneralPref.Action>
func transform(_ source: Observable<Pair>) -> Observable<Pair> {
return source.map { pair in
var state = pair.state
switch pair.action {
case let .setOpenOnLaunch(value):
state.openNewMainWindowOnLaunch = value
case let .setOpenOnReactivation(value):
state.openNewMainWindowOnReactivation = value
case let .setIgnorePatterns(patterns):
state.openQuickly.ignorePatterns = patterns
state.openQuickly.ignoreToken = Token()
}
return StateActionPair(state: state, action: pair.action)
}
}
}