1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-28 08:13:17 +03:00

GH-322 Observe subscriptions via MainScheduler

This commit is contained in:
Tae Won Ha 2016-11-03 19:57:19 +01:00
parent 26009e1073
commit d6053e5c05
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
4 changed files with 8 additions and 8 deletions

View File

@ -60,6 +60,7 @@ class FileBrowserComponent: ViewComponent {
self.fileItemService.sink self.fileItemService.sink
.filter { $0 is FileItemServiceChange } .filter { $0 is FileItemServiceChange }
.map { $0 as! FileItemServiceChange } .map { $0 as! FileItemServiceChange }
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [unowned self] action in .subscribe(onNext: { [unowned self] action in
switch action { switch action {
case let .childrenChanged(root, fileItem): case let .childrenChanged(root, fileItem):
@ -69,9 +70,7 @@ class FileBrowserComponent: ViewComponent {
// FIXME: restore expanded states // FIXME: restore expanded states
if fileItem?.url == self.cwd { if fileItem?.url == self.cwd {
DispatchUtils.gui { self.fileView.reloadItem(nil, reloadChildren: true)
self.fileView.reloadItem(nil, reloadChildren: true)
}
} }
guard self.fileView.row(forItem: fileItem) > -1 else { guard self.fileView.row(forItem: fileItem) > -1 else {
@ -79,9 +78,7 @@ class FileBrowserComponent: ViewComponent {
} }
// FIXME: restore expanded states // FIXME: restore expanded states
DispatchUtils.gui { self.fileView.reloadItem(fileItem, reloadChildren: true)
self.fileView.reloadItem(fileItem, reloadChildren: true)
}
} }
}) })
.addDisposableTo(self.disposeBag) .addDisposableTo(self.disposeBag)
@ -104,6 +101,7 @@ class FileBrowserComponent: ViewComponent {
return source return source
.filter { $0 is MainWindowAction } .filter { $0 is MainWindowAction }
.map { $0 as! MainWindowAction } .map { $0 as! MainWindowAction }
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [unowned self] action in .subscribe(onNext: { [unowned self] action in
switch action { switch action {
case let .changeCwd(mainWindow: mainWindow): case let .changeCwd(mainWindow: mainWindow):

View File

@ -34,9 +34,9 @@ extension URL {
do { do {
try (self as NSURL).getResourceValue(&rsrc, forKey: URLResourceKey(rawValue: key)) try (self as NSURL).getResourceValue(&rsrc, forKey: URLResourceKey(rawValue: key))
} catch { } catch let error as NSError {
// FIXME error handling // FIXME error handling
print("\(#function): \(self) -> ERROR while getting \(key)") print("\(#function): \(self) -> ERROR while getting \(key): \(error)")
return false return false
} }

View File

@ -178,6 +178,7 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate, NSUserInterfaceVal
!appearanceData.editorFont.isEqual(to: self.neoVimView.font) !appearanceData.editorFont.isEqual(to: self.neoVimView.font)
|| appearanceData.editorUsesLigatures != self.neoVimView.usesLigatures || appearanceData.editorUsesLigatures != self.neoVimView.usesLigatures
} }
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [unowned self] appearance in .subscribe(onNext: { [unowned self] appearance in
self.neoVimView.usesLigatures = appearance.editorUsesLigatures self.neoVimView.usesLigatures = appearance.editorUsesLigatures
self.neoVimView.font = appearance.editorFont self.neoVimView.font = appearance.editorFont

View File

@ -142,6 +142,7 @@ class OpenQuicklyWindowComponent: WindowComponent,
self.mainWindow?.sink self.mainWindow?.sink
.filter { $0 is MainWindowAction } .filter { $0 is MainWindowAction }
.map { $0 as! MainWindowAction } .map { $0 as! MainWindowAction }
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [unowned self] action in .subscribe(onNext: { [unowned self] action in
switch action { switch action {
case .close: case .close: