Skip to content

Commit

Permalink
Merge pull request #13 from Ericarman/bug/memeory-leak-fix
Browse files Browse the repository at this point in the history
Fix memory leak on webView subscribe
  • Loading branch information
kylehickinson authored Dec 31, 2024
2 parents b500add + fd42466 commit 8abc88c
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 8abc88c

Please sign in to comment.