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

[docs] State Management reference using GlobalWindowEvent #2951

Open
abarrafo opened this issue Nov 7, 2024 · 0 comments
Open

[docs] State Management reference using GlobalWindowEvent #2951

abarrafo opened this issue Nov 7, 2024 · 0 comments

Comments

@abarrafo
Copy link

abarrafo commented Nov 7, 2024

Docs reference using GlobalWindowEvent

use tauri::{Builder, GlobalWindowEvent, Manager};

....

// In an event handler:
fn on_window_event(event: GlobalWindowEvent) {
    // Get a handle to the app so we can get the global state.
    let app_handle = event.window().app_handle();
    let state = app_handle.state::<Mutex<AppState>>();

    // Lock the mutex to mutably access the state.
    let mut state = state.lock().unwrap();
    state.counter += 1;
}

But, as far as I can see, GlobalWindowEvent on v2 does not exist, instead we have WindowEvent, which does not give you access to the underlying window()?

https://v2.tauri.app/develop/state-management/#accessing-state

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Nov 7, 2024
@github-project-automation github-project-automation bot moved this to 🪵 Backlog in Documentation Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🪵 Backlog
Development

No branches or pull requests

1 participant