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

35 lines
781 B
Swift
Raw Normal View History

2017-02-28 00:45:26 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import RxSwift
2017-03-29 21:10:11 +03:00
class GeneralPrefReducer: Reducer {
2017-02-28 00:45:26 +03:00
typealias Pair = StateActionPair<AppState, GeneralPref.Action>
2017-03-29 21:17:45 +03:00
func reduce(_ source: Observable<Pair>) -> Observable<Pair> {
2017-02-28 00:45:26 +03:00
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)
}
}
}