-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from cybozu/fix-infinite-loop-3
Fix infinite loop due to `objectWillChange` firing
- Loading branch information
Showing
4 changed files
with
25 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import SwiftUI | ||
import WebKit | ||
|
||
struct SetUpWebViewProxyAction { | ||
let action: (WKWebView) -> Void | ||
|
||
func callAsFunction(_ webView: WKWebView) { | ||
action(webView) | ||
} | ||
} | ||
|
||
private struct SetUpWebViewProxyActionKey: EnvironmentKey { | ||
static var defaultValue = SetUpWebViewProxyAction(action: { _ in }) | ||
} | ||
|
||
extension EnvironmentValues { | ||
var setUpWebViewProxy: SetUpWebViewProxyAction { | ||
get { self[SetUpWebViewProxyActionKey.self] } | ||
set { self[SetUpWebViewProxyActionKey.self] = newValue } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters