Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to grab pageURL as a state object #8

Closed
DaeheeCodes opened this issue Jun 10, 2022 · 1 comment
Closed

Add ability to grab pageURL as a state object #8

DaeheeCodes opened this issue Jun 10, 2022 · 1 comment

Comments

@DaeheeCodes
Copy link

Love your work on this, makes it so much easier for me to implement swiftui webview.
I was playing around with it to see if I can save the page's url but because the your webview package is constructed on load i couldnt use the general " webView.url" call.

I added the following code on your WebViewCoordinator extension after calling " public internal(set) var pageURL: String?
" on your WebViewState constructor

webView.evaluateJavaScript("document.URL.toString()") { (response, error) in
if let url = response as? String {
var newState = self.webView.state
newState.pageURL = url
self.webView.state = newState
}
}

Think itd be a great function to have especially for newbies like me so they dont have to go chasing around the code trying to figure out how to load the url : )

@gordan-glavas-codecons
Copy link
Collaborator

Hi, thanks for the feedback! Version 1.0.7 now contains pageURL state property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants