Skip to content

Commit

Permalink
Observer added to reflect instant changes on UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Sah committed Sep 28, 2024
1 parent f3a9c83 commit 0c83c3a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct UpdatingWindowController: DynamicProperty {
private var objectWillChangeCancellable: AnyCancellable?
private var utilityAreaCancellable: AnyCancellable? // ``ViewCommands`` needs this.
private var windowCancellable: AnyCancellable?
private var activeEditorCancellable: AnyCancellable?

init() {
windowCancellable = NSApp.publisher(for: \.keyWindow).sink { [weak self] window in
Expand All @@ -51,6 +52,8 @@ struct UpdatingWindowController: DynamicProperty {
objectWillChangeCancellable = nil
utilityAreaCancellable?.cancel()
utilityAreaCancellable = nil
activeEditorCancellable?.cancel()
activeEditorCancellable = nil

self.controller = controller

Expand All @@ -60,6 +63,10 @@ struct UpdatingWindowController: DynamicProperty {
utilityAreaCancellable = controller?.workspace?.utilityAreaModel?.objectWillChange.sink { [weak self] in
self?.objectWillChange.send()
}
let activeEditor = controller?.workspace?.editorManager?.activeEditor
activeEditorCancellable = activeEditor?.objectWillChange.sink { [weak self] in
self?.objectWillChange.send()
}
self.objectWillChange.send()
}
}
Expand Down

0 comments on commit 0c83c3a

Please sign in to comment.