Skip to content

Commit

Permalink
Fix memory weak on webView subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericarman committed Dec 31, 2024
1 parent b733415 commit fd42466
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/WebView/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class WebViewStore: ObservableObject {

private func setupObservers() {
func subscriber<Value>(for keyPath: KeyPath<WKWebView, Value>) -> NSKeyValueObservation {
return webView.observe(keyPath, options: [.prior]) { _, change in
return webView.observe(keyPath, options: [.prior]) { [weak self] _, change in
guard let self else { return }

if change.isPrior {
self.objectWillChange.send()
objectWillChange.send()
}
}
}
Expand Down

0 comments on commit fd42466

Please sign in to comment.