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

GH-213 Wire components in AppDelegate

This commit is contained in:
Tae Won Ha 2016-07-26 22:51:05 +02:00
parent 0073fec982
commit 6897d512ac
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 32 additions and 7 deletions

View File

@ -10,14 +10,38 @@ import PureLayout
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
private let prefStore = PrefStore(source: Observable.empty())
private let disposeBag = DisposeBag()
private let changeSubject = PublishSubject<Any>()
private let changeSink: Observable<Any>
private let actionSink: Observable<Any>
private let prefStore: PrefStore
private let mainWindowManager: MainWindowManager
private let prefWindowComponent = PrefWindowComponent(source: Observable.empty())
private let prefWindowComponent: PrefWindowComponent
override init() {
self.mainWindowManager = MainWindowManager(prefWindowComponent: self.prefWindowComponent)
self.changeSink = self.changeSubject.asObservable()
self.prefWindowComponent = PrefWindowComponent(source: self.changeSink)
self.mainWindowManager = MainWindowManager(source: self.changeSink)
self.actionSink = [ self.prefWindowComponent ]
.map { $0.sink }
.toObservable()
.flatMap { $0 }
self.prefStore = PrefStore(source: self.actionSink)
super.init()
[ self.prefStore ]
.map { $0.sink }
.toObservable()
.flatMap { $0 }
.subscribe(self.changeSubject)
.addDisposableTo(self.disposeBag)
}
@IBAction func debugSomething(sender: AnyObject!) {

View File

@ -8,15 +8,15 @@ import RxSwift
class MainWindowManager {
private let prefWindowComponent: PrefWindowComponent
private let source: Observable<Any>
private var mainWindowComponents = [String:MainWindowComponent]()
init(prefWindowComponent: PrefWindowComponent) {
self.prefWindowComponent = prefWindowComponent
init(source: Observable<Any>) {
self.source = source
}
func newMainWindow() {
let mainWindowComponent = MainWindowComponent(source: self.prefWindowComponent.sink, manager: self)
let mainWindowComponent = MainWindowComponent(source: self.source, manager: self)
self.mainWindowComponents[mainWindowComponent.uuid] = mainWindowComponent
}

View File

@ -42,6 +42,7 @@ class PrefStore: Store {
}
self.subject.onNext(self.data)
self.addReactions()
}
private func prefDataFromDict(prefs: [String: AnyObject]) -> PrefData {