Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15002c0

Browse files
committed
run_return on mobile
1 parent edaac28 commit 15002c0

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

.changes/run-return-mobile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-runtime": minor:feat
3+
---
4+
5+
`Runtime::run_return` now must also be implemented on mobile targets.

crates/tauri-runtime-wry/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2836,14 +2836,20 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
28362836
self.event_loop.run(event_handler)
28372837
}
28382838

2839-
#[cfg(desktop)]
2839+
#[cfg(not(target_os = "ios"))]
28402840
fn run_return<F: FnMut(RunEvent<T>) + 'static>(mut self, callback: F) -> i32 {
28412841
use tao::platform::run_return::EventLoopExtRunReturn;
28422842

28432843
let event_handler = make_event_handler(&self, callback);
28442844

28452845
self.event_loop.run_return(event_handler)
28462846
}
2847+
2848+
#[cfg(target_os = "ios")]
2849+
fn run_return<F: FnMut(RunEvent<T>) + 'static>(mut self, callback: F) -> i32 {
2850+
self.run(callback);
2851+
0
2852+
}
28472853
}
28482854

28492855
fn make_event_handler<T, F>(

crates/tauri-runtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
438438
fn run_iteration<F: FnMut(RunEvent<T>) + 'static>(&mut self, callback: F);
439439

440440
/// Equivalent to [`Runtime::run`] but returns the exit code instead of exiting the process.
441-
#[cfg(desktop)]
442441
fn run_return<F: FnMut(RunEvent<T>) + 'static>(self, callback: F) -> i32;
443442

444443
/// Run the webview runtime.

crates/tauri/src/app.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ impl<R: Runtime> App<R> {
11031103
///
11041104
/// ## Platform-specific
11051105
///
1106-
/// - **iOS / Android**: Unsupported.
1106+
/// - **iOS**: Unsupported. The application will fallback to [`run`](Self::run).
11071107
///
11081108
/// # Panics
11091109
///
@@ -1125,7 +1125,6 @@ impl<R: Runtime> App<R> {
11251125
///
11261126
/// std::process::exit(exit_code);
11271127
/// ```
1128-
#[cfg(desktop)]
11291128
pub fn run_return<F: FnMut(&AppHandle<R>, RunEvent) + 'static>(mut self, mut callback: F) -> i32 {
11301129
let manager = self.manager.clone();
11311130
let app_handle = self.handle().clone();

crates/tauri/src/test/mock_runtime.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,6 @@ impl<T: UserEvent> Runtime<T> for MockRuntime {
11881188
))]
11891189
fn run_iteration<F: FnMut(RunEvent<T>)>(&mut self, callback: F) {}
11901190

1191-
#[cfg(desktop)]
11921191
fn run_return<F: FnMut(RunEvent<T>) + 'static>(self, callback: F) -> i32 {
11931192
self.run(callback);
11941193

0 commit comments

Comments
 (0)