Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions Sources/PerceptionCore/_PerceptionRegistrar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,9 @@ internal struct _PerceptionRegistrar: Sendable {
}
}

internal mutating func deinitialize() -> [@Sendable () -> Void] {
var trackers = [@Sendable () -> Void]()
for (keyPath, ids) in lookups {
for id in ids {
if let tracker = perceptions[id]?.willSetTracker {
trackers.append({
tracker(keyPath)
})
}
}
}
internal mutating func cancelAll() {
perceptions.removeAll()
lookups.removeAll()
return trackers
}

internal mutating func willSet(keyPath: AnyKeyPath) -> [@Sendable (AnyKeyPath) -> Void] {
Expand Down Expand Up @@ -168,13 +157,10 @@ internal struct _PerceptionRegistrar: Sendable {
state.withCriticalRegion { $0.cancel(id) }
}

internal func deinitialize() {
let tracking = state.withCriticalRegion { $0.deinitialize() }
for action in tracking {
action()
}
internal func cancelAll() {
state.withCriticalRegion { $0.cancelAll() }
}

internal func willSet<Subject: Perceptible, Member>(
_ subject: Subject,
keyPath: KeyPath<Subject, Member>
Expand Down Expand Up @@ -203,7 +189,7 @@ internal struct _PerceptionRegistrar: Sendable {
}

deinit {
context.deinitialize()
context.cancelAll()
}
}

Expand Down