Skip to content

Accessing from Rust

When the ManagerExt trait is in scope, you can access your stores from any type that implements the Manager trait (e.g. AppHandle, Window, WebviewWindow).

A list of all available methods for the stores can be found here.

rust
use tauri_plugin_vue::ManagerExt;

#[tauri::command]
fn get_counter(app: AppHandle) -> i32 {
  app
    .vue()
    .get::<i32>("store", "counter")
    .unwrap()
}

Watching for changes

The watch method can be used to set up a closure that will be called whenever the state of the store changes.

rust
use tauri_plugin_vue::ManagerExt;

#[tauri::command]
fn watch_store(app: AppHandle) {
  app.vue().watch("store", |app| {
    let counter = app
      .vue()
      .get::<i32>("store", "counter")?;

    println!("counter: {counter}");

    Ok(())
  });
}