Skip to content

Commit

Permalink
refactor!: change Webview::navigate to return result (#10134)
Browse files Browse the repository at this point in the history
closes #9935
  • Loading branch information
amrbashir authored Jun 27, 2024
1 parent 77d4421 commit 3afe828
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/webview-navigate-result.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": "patch:breaking"
---

Changed `WebviewWindow::navigate` and `Webview::navigate` method signature to return a `Result`
4 changes: 2 additions & 2 deletions core/tauri/src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,8 @@ fn main() {
}

/// Navigates the webview to the defined url.
pub fn navigate(&mut self, url: Url) {
self.webview.dispatcher.navigate(url).unwrap();
pub fn navigate(&mut self, url: Url) -> crate::Result<()> {
self.webview.dispatcher.navigate(url).map_err(Into::into)
}

fn is_local_url(&self, current_url: &Url) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/src/webview/webview_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1665,8 +1665,8 @@ impl<R: Runtime> WebviewWindow<R> {
}

/// Navigates the webview to the defined url.
pub fn navigate(&mut self, url: Url) {
self.webview.navigate(url);
pub fn navigate(&mut self, url: Url) -> crate::Result<()> {
self.webview.navigate(url)
}

/// Handles this window receiving an [`crate::webview::InvokeRequest`].
Expand Down

0 comments on commit 3afe828

Please sign in to comment.