tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.77k stars 2.45k forks source link

v2 requiring an instance of App, AppHandle or Window to get access to path functions like home_dir() #10478

Open zoaha opened 1 month ago

zoaha commented 1 month ago

in v1, all you needed was to import and you had access to paths:

use tauri::api::path::home_dir;

#[tauri::command]
fn getPath() -> Result<PathBuf> {
   home_dir()

but now in v2, you need an instance of AppHandle:

use tauri::Manager;

#[tauri::command]
fn getPath(app: tauri::AppHandle) -> Result<PathBuf> {
   app.path().home_dir()

is this intended? also there's no documentation I could find on v2 usage of paths

chippers commented 1 month ago

It is intended, but I think documentation is a good answer to it.

Thanks for filing :)