Skip to content

Commit 132d2f4

Browse files
committed
Add watchdog to RuntimeListings to watch if changes have occured
1 parent 334fa99 commit 132d2f4

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

HeaderViewer/RuntimeListings.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ final class RuntimeListings: ObservableObject {
7373
}
7474
.store(in: &subscriptions)
7575

76+
Timer.publish(every: 15, on: .main, in: .default)
77+
.autoconnect()
78+
.sink { [weak self] _ in
79+
guard let self else { return }
80+
81+
let classList = CDUtilities.classNames()
82+
let protocolList = CDUtilities.protocolNames()
83+
84+
let refClassList = self.classList
85+
let refProtocolList = self.protocolList
86+
87+
if classList != refClassList {
88+
Self.logger.error("Watchdog: classList is out-of-date")
89+
self.classList = classList
90+
}
91+
if protocolList != refProtocolList {
92+
Self.logger.error("Watchdog: protocolList is out-of-date")
93+
self.protocolList = protocolList
94+
}
95+
}
96+
.store(in: &subscriptions)
7697
}
7798

7899
func isImageLoaded(path: String) -> Bool {

0 commit comments

Comments
 (0)