1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 23:02:35 +03:00

Adapt to RxSwift 6.2

This commit is contained in:
Tae Won Ha 2021-06-18 08:51:22 +02:00
parent 6254fa99e4
commit 507e2d6973
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
21 changed files with 28 additions and 28 deletions

View File

@ -62,7 +62,7 @@ extension NvimView: NSTouchBarDelegate, NSScrubberDataSource, NSScrubberDelegate
func updateTouchBarCurrentBuffer() { func updateTouchBarCurrentBuffer() {
self self
.allTabs() .allTabs()
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onSuccess: { [weak self] in .subscribe(onSuccess: { [weak self] in
self?.tabsCache = $0 self?.tabsCache = $0
@ -83,7 +83,7 @@ extension NvimView: NSTouchBarDelegate, NSScrubberDataSource, NSScrubberDelegate
func updateTouchBarTab() { func updateTouchBarTab() {
self self
.allTabs() .allTabs()
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onSuccess: { [weak self] in .subscribe(onSuccess: { [weak self] in
self?.tabsCache = $0 self?.tabsCache = $0

View File

@ -186,7 +186,7 @@ extension NvimView {
if event == .vimenter { if event == .vimenter {
Completable Completable
.empty() .empty()
.observeOn(SerialDispatchQueueScheduler(qos: .userInitiated)) .observe(on: SerialDispatchQueueScheduler(qos: .userInitiated))
.andThen( .andThen(
Completable.create { completable in Completable.create { completable in
self.rpcEventSubscriptionCondition.wait(for: 5) self.rpcEventSubscriptionCondition.wait(for: 5)
@ -245,7 +245,7 @@ extension NvimView {
try? self.api try? self.api
.stop() .stop()
.andThen(self.bridge.forceQuit()) .andThen(self.bridge.forceQuit())
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.wait(onCompleted: { [weak self] in .wait(onCompleted: { [weak self] in
self?.bridgeLogger.fault("Successfully force-closed the bridge.") self?.bridgeLogger.fault("Successfully force-closed the bridge.")
}, onError: { [weak self] in }, onError: { [weak self] in

View File

@ -78,12 +78,12 @@ public extension PrimitiveSequence where Trait == SingleTrait {
let disposable = self.subscribe(onSuccess: { result in let disposable = self.subscribe(onSuccess: { result in
value = result value = result
condition.lock() condition.lock()
defer { condition.unlock() } defer { condition.unlock() }
trigger = true trigger = true
condition.broadcast() condition.broadcast()
}, onError: { _ in }, onFailure: { _ in
condition.lock() condition.lock()
defer { condition.unlock() } defer { condition.unlock() }
trigger = true trigger = true

View File

@ -41,7 +41,7 @@ class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
self.updateViews() self.updateViews()
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if self.useInteractiveZsh != state.mainWindowTemplate.useInteractiveZsh if self.useInteractiveZsh != state.mainWindowTemplate.useInteractiveZsh
|| self.useSnapshotUpdate != state.useSnapshotUpdate || self.useSnapshotUpdate != state.useSnapshotUpdate

View File

@ -77,7 +77,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
) )
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { appState in .subscribe(onNext: { appState in
self.hasMainWindows = !appState.mainWindows.isEmpty self.hasMainWindows = !appState.mainWindows.isEmpty
self.hasDirtyWindows = appState.mainWindows.values.reduce(false) { $1.isDirty ? true : $0 } self.hasDirtyWindows = appState.mainWindows.values.reduce(false) { $1.isDirty ? true : $0 }

View File

@ -53,7 +53,7 @@ class AppearancePref: PrefPane, NSComboBoxDelegate, NSControlTextEditingDelegate
sharedFontManager.target = self sharedFontManager.target = self
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
let appearance = state.mainWindowTemplate.appearance let appearance = state.mainWindowTemplate.appearance

View File

@ -46,7 +46,7 @@ class BuffersList: NSView,
self.addViews() self.addViews()
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if state.viewToBeFocused != nil, if state.viewToBeFocused != nil,
case .bufferList = state.viewToBeFocused! case .bufferList = state.viewToBeFocused!

View File

@ -50,7 +50,7 @@ class FileBrowser: NSView,
self.innerCustomToolbar.fileBrowser = self self.innerCustomToolbar.fileBrowser = self
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if self.cwd != state.cwd { if self.cwd != state.cwd {
self.cwd = state.cwd self.cwd = state.cwd

View File

@ -51,7 +51,7 @@ class FileOutlineView: NSOutlineView,
self.delegate = self self.delegate = self
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if state.viewToBeFocused != nil, case .fileBrowser = state.viewToBeFocused! { if state.viewToBeFocused != nil, case .fileBrowser = state.viewToBeFocused! {
self.beFirstResponder() self.beFirstResponder()

View File

@ -41,7 +41,7 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
.selectItem(at: indexToAfterLastWindowAction.firstIndex(of: state.afterLastWindowAction) ?? 0) .selectItem(at: indexToAfterLastWindowAction.firstIndex(of: state.afterLastWindowAction) ?? 0)
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if self.openWhenLaunchingCheckbox.boolState != state.openNewMainWindowOnLaunch { if self.openWhenLaunchingCheckbox.boolState != state.openNewMainWindowOnLaunch {
self.openWhenLaunchingCheckbox.boolState = state.openNewMainWindowOnLaunch self.openWhenLaunchingCheckbox.boolState = state.openNewMainWindowOnLaunch

View File

@ -50,7 +50,7 @@ class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
} }
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if state.viewToBeFocused != nil, if state.viewToBeFocused != nil,
case .htmlPreview = state.viewToBeFocused! { self.beFirstResponder() } case .htmlPreview = state.viewToBeFocused! { self.beFirstResponder() }

View File

@ -35,7 +35,7 @@ class KeysPref: PrefPane, UiComponent, NSTextFieldDelegate {
self.updateViews() self.updateViews()
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if self.isLeftOptionMeta != state.mainWindowTemplate.isLeftOptionMeta if self.isLeftOptionMeta != state.mainWindowTemplate.isLeftOptionMeta
|| self.isRightOptionMeta != state.mainWindowTemplate.isRightOptionMeta || self.isRightOptionMeta != state.mainWindowTemplate.isRightOptionMeta

View File

@ -166,7 +166,7 @@ extension MainWindow {
@IBAction func saveDocument(_: Any?) { @IBAction func saveDocument(_: Any?) {
self.neoVimView self.neoVimView
.currentBuffer() .currentBuffer()
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.flatMapCompletable { curBuf -> Completable in .flatMapCompletable { curBuf -> Completable in
if curBuf.url == nil { if curBuf.url == nil {
self.savePanelSheet { self.savePanelSheet {
@ -187,7 +187,7 @@ extension MainWindow {
@IBAction func saveDocumentAs(_: Any?) { @IBAction func saveDocumentAs(_: Any?) {
self.neoVimView self.neoVimView
.currentBuffer() .currentBuffer()
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onSuccess: { curBuf in .subscribe(onSuccess: { curBuf in
self.savePanelSheet { url in self.savePanelSheet { url in
self.neoVimView self.neoVimView

View File

@ -275,7 +275,7 @@ class MainWindow: NSObject,
private func subscribeToNvimViewEvents() { private func subscribeToNvimViewEvents() {
self.neoVimView.events self.neoVimView.events
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] event in .subscribe(onNext: { [weak self] event in
switch event { switch event {
case .neoVimStopped: self?.neoVimStopped() case .neoVimStopped: self?.neoVimStopped()
@ -325,7 +325,7 @@ class MainWindow: NSObject,
private func subscribeToStateChange(source: Observable<StateType>) { private func subscribeToStateChange(source: Observable<StateType>) {
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if self.isClosing { if self.isClosing {
return return

View File

@ -79,7 +79,7 @@ class MarkdownTool: NSView, UiComponent, WKNavigationDelegate {
if let url = state.preview.server { self.webview.load(URLRequest(url: url)) } if let url = state.preview.server { self.webview.load(URLRequest(url: url)) }
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if state.viewToBeFocused != nil, if state.viewToBeFocused != nil,
case .markdownPreview = state.viewToBeFocused! case .markdownPreview = state.viewToBeFocused!

View File

@ -55,7 +55,7 @@ class OpenQuicklyWindow: NSObject,
self.addViews() self.addViews()
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] state in self?.subscription(state) }) .subscribe(onNext: { [weak self] state in self?.subscription(state) })
.disposed(by: self.disposeBag) .disposed(by: self.disposeBag)
} }
@ -145,7 +145,7 @@ class OpenQuicklyWindow: NSObject,
self.cwdControl.url = cwd self.cwdControl.url = cwd
self.searchStream self.searchStream
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] pattern in .subscribe(onNext: { [weak self] pattern in
self?.scanAndScore(pattern) self?.scanAndScore(pattern)
}) })

View File

@ -40,7 +40,7 @@ class PrefWindow: NSObject,
self.addViews() self.addViews()
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
if state.preferencesOpen.payload == false { if state.preferencesOpen.payload == false {
self.openStatusMark = state.preferencesOpen.mark self.openStatusMark = state.preferencesOpen.mark

View File

@ -112,7 +112,7 @@ protocol UiComponent {
class ActionEmitter { class ActionEmitter {
var observable: Observable<ReduxTypes.ActionType> { var observable: Observable<ReduxTypes.ActionType> {
self.subject.asObservable().observeOn(self.scheduler) self.subject.asObservable().observe(on: self.scheduler)
} }
func typedEmit<T>() -> (T) -> Void {{ (action: T) in self.subject.onNext(action) } } func typedEmit<T>() -> (T) -> Void {{ (action: T) in self.subject.onNext(action) } }
@ -149,7 +149,7 @@ class ReduxContext {
init(initialState: ReduxTypes.StateType) { init(initialState: ReduxTypes.StateType) {
self.state = initialState self.state = initialState
self.stateSource = self.stateSubject.asObservable().observeOn(self.stateScheduler) self.stateSource = self.stateSubject.asObservable().observe(on: self.stateScheduler)
} }
func terminate() { func terminate() {

View File

@ -33,7 +33,7 @@ class ToolsPref: PrefPane, UiComponent {
self.updateViews() self.updateViews()
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { _ in .subscribe(onNext: { _ in
self.updateViews() self.updateViews()

View File

@ -104,7 +104,7 @@ class UiComponentTemplate: UiComponent {
// react to the new state // react to the new state
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe( .subscribe(
onNext: { _ in onNext: { _ in
Swift.print("Hello, \(self.someField)") Swift.print("Hello, \(self.someField)")

View File

@ -26,7 +26,7 @@ class UiRoot: UiComponent {
self.prefWindow = PrefWindow(source: source, emitter: emitter, state: state) self.prefWindow = PrefWindow(source: source, emitter: emitter, state: state)
source source
.observeOn(MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { state in .subscribe(onNext: { state in
let uuidsInState = Set(state.mainWindows.keys) let uuidsInState = Set(state.mainWindows.keys)