-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: expose app exit via JS process API #14767
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'tauri': 'minor:feat' | ||
| '@tauri-apps/api': 'minor:feat' | ||
| --- | ||
|
|
||
| Expose app exit as a JS process API backed by the core app exit command. |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright 2019-2024 Tauri Programme within The Commons Conservancy | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| import { invoke } from './core' | ||
|
|
||
| /** | ||
| * Process-related APIs. | ||
| * | ||
| * @module | ||
| */ | ||
|
|
||
| /** | ||
| * Exits the app. | ||
| * | ||
| * @param exitCode - The exit code to use. Defaults to `0`. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { exit } from '@tauri-apps/api/process'; | ||
| * await exit(); | ||
| * ``` | ||
| * | ||
| * @since 2.10.0 | ||
| */ | ||
| async function exit(exitCode?: number): Promise<void> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's move this to |
||
| const payload = exitCode === undefined ? {} : { exitCode } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could put the default value in the js side? (e.g. |
||
| return invoke('plugin:app|exit', payload) | ||
| } | ||
|
|
||
| export { exit } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on Android this should route to the AppPlugin for graceful shutdown