1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 10:02:36 +03:00
vimr/VimR/FileBrowserTransformer.swift
2017-02-26 10:55:07 +01:00

35 lines
796 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import RxSwift
class FileBrowserTransformer: Transformer {
typealias Pair = StateActionPair<UuidState<MainWindow.State>, FileBrowser.Action>
func transform(_ 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.append(Marked([url: mode]))
state.focusedView = .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)
}
}
}