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:
parent
0073fec982
commit
6897d512ac
@ -10,14 +10,38 @@ import PureLayout
|
|||||||
@NSApplicationMain
|
@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
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 mainWindowManager: MainWindowManager
|
||||||
private let prefWindowComponent = PrefWindowComponent(source: Observable.empty())
|
private let prefWindowComponent: PrefWindowComponent
|
||||||
|
|
||||||
override init() {
|
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()
|
super.init()
|
||||||
|
|
||||||
|
[ self.prefStore ]
|
||||||
|
.map { $0.sink }
|
||||||
|
.toObservable()
|
||||||
|
.flatMap { $0 }
|
||||||
|
.subscribe(self.changeSubject)
|
||||||
|
.addDisposableTo(self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func debugSomething(sender: AnyObject!) {
|
@IBAction func debugSomething(sender: AnyObject!) {
|
||||||
|
@ -8,15 +8,15 @@ import RxSwift
|
|||||||
|
|
||||||
class MainWindowManager {
|
class MainWindowManager {
|
||||||
|
|
||||||
private let prefWindowComponent: PrefWindowComponent
|
private let source: Observable<Any>
|
||||||
private var mainWindowComponents = [String:MainWindowComponent]()
|
private var mainWindowComponents = [String:MainWindowComponent]()
|
||||||
|
|
||||||
init(prefWindowComponent: PrefWindowComponent) {
|
init(source: Observable<Any>) {
|
||||||
self.prefWindowComponent = prefWindowComponent
|
self.source = source
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMainWindow() {
|
func newMainWindow() {
|
||||||
let mainWindowComponent = MainWindowComponent(source: self.prefWindowComponent.sink, manager: self)
|
let mainWindowComponent = MainWindowComponent(source: self.source, manager: self)
|
||||||
self.mainWindowComponents[mainWindowComponent.uuid] = mainWindowComponent
|
self.mainWindowComponents[mainWindowComponent.uuid] = mainWindowComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ class PrefStore: Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.subject.onNext(self.data)
|
self.subject.onNext(self.data)
|
||||||
|
self.addReactions()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func prefDataFromDict(prefs: [String: AnyObject]) -> PrefData {
|
private func prefDataFromDict(prefs: [String: AnyObject]) -> PrefData {
|
||||||
|
Loading…
Reference in New Issue
Block a user