1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-29 12:04:11 +03:00
vimr/VimR/FileBrowserReducer.swift

35 lines
773 B
Swift
Raw Normal View History

2017-02-24 02:24:30 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import RxSwift
2017-03-29 21:10:11 +03:00
class FileBrowserReducer: Reducer {
2017-02-24 02:24:30 +03:00
2017-02-24 12:51:24 +03:00
typealias Pair = StateActionPair<UuidState<MainWindow.State>, FileBrowser.Action>
2017-02-24 02:24:30 +03:00
2017-03-29 21:17:45 +03:00
func reduce(_ source: Observable<Pair>) -> Observable<Pair> {
2017-02-24 02:24:30 +03:00
return source.map { pair in
var state = pair.state.payload
switch pair.action {
case let .open(url, mode):
state.urlsToOpen[url] = mode
2017-03-31 20:32:01 +03:00
state.viewToBeFocused = .neoVimView
2017-02-24 02:24:30 +03:00
case let .setAsWorkingDirectory(url):
state.cwd = url
case let .setShowHidden(show):
state.fileBrowserShowHidden = show
2017-02-24 02:24:30 +03:00
}
return StateActionPair(state: UuidState(uuid: state.uuid, state: state), action: pair.action)
}
}
}