1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 01:32:04 +03:00
vimr/VimR/FileBrowserReducer.swift
2017-03-31 19:53:40 +02:00

35 lines
773 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import RxSwift
class FileBrowserReducer: Reducer {
typealias Pair = StateActionPair<UuidState<MainWindow.State>, FileBrowser.Action>
func reduce(_ source: Observable<Pair>) -> Observable<Pair> {
return source.map { pair in
var state = pair.state.payload
switch pair.action {
case let .open(url, mode):
state.urlsToOpen[url] = mode
state.viewToBeFocused = .neoVimView
case let .setAsWorkingDirectory(url):
state.cwd = url
case let .setShowHidden(show):
state.fileBrowserShowHidden = show
}
return StateActionPair(state: UuidState(uuid: state.uuid, state: state), action: pair.action)
}
}
}