Skip to content

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

Merged
amrbashir merged 2 commits into
tauri-apps:devfrom
Rajaniraiyn:const-tauri-dev
May 27, 2024
Merged

refactor: rename tauri::dev to is_dev and mark as constant fn#9890
amrbashir merged 2 commits into
tauri-apps:devfrom
Rajaniraiyn:const-tauri-dev

Conversation

@Rajaniraiyn
Copy link
Copy Markdown
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
@amrbashir
Copy link
Copy Markdown
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