Add doc comment example for App::run (#2824)

This commit is contained in:
Kasper 2021-11-13 15:12:58 +01:00 committed by GitHub
parent 7c6c7adcc4
commit dfe508d492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -457,6 +457,21 @@ impl<R: Runtime> App<R> {
}
/// Runs the application.
///
/// # Example
/// ```rust,ignore
/// fn main() {
/// let app = tauri::Builder::default()
/// .build(tauri::generate_context!())
/// .expect("error while building tauri application");
/// app.run(|_app_handle, event| match event {
/// tauri::Event::ExitRequested { api, .. } => {
/// api.prevent_exit();
/// }
/// _ => {}
/// });
/// }
/// ```
pub fn run<F: FnMut(&AppHandle<R>, Event) + 'static>(mut self, mut callback: F) {
let app_handle = self.handle();
let manager = self.manager.clone();