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

refactor: rename tauri::dev to is_dev and mark as constant fn #9890

Merged
merged 2 commits into from
May 27, 2024

Conversation

Rajaniraiyn
Copy link
Contributor

this enables the tauri::dev() can be used as const or static

Example

// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;

static IS_DEV: bool = tauri::dev();

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_autostart::init(
            MacosLauncher::LaunchAgent,
            Some(vec![]),
        ))
        .plugin(tauri_plugin_shell::init())
        .setup(|app| {
            if IS_DEV {
                let window = app.get_webview_window("main").unwrap();
                window.open_devtools();
            } else {
                use tauri_plugin_autostart::ManagerExt;
                let autostart_manager = app.autolaunch();
                if !autostart_manager.is_enabled().unwrap() {
                    let _ = autostart_manager.enable();
                }
            }
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

this enables the `tauri::dev()` can be used as const or static
@Rajaniraiyn Rajaniraiyn requested a review from a team as a code owner May 27, 2024 09:22
@amrbashir amrbashir changed the title refactor: made tauri::dev as constant function refactor: rename tauri::dev to is_dev and mark as constant fn May 27, 2024
@amrbashir amrbashir merged commit aaecb6a into tauri-apps:dev May 27, 2024
19 checks passed
@amrbashir
Copy link
Member

Thank you

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

Successfully merging this pull request may close these issues.

2 participants