Skip to content

Commit c8f819b

Browse files
committed
fix: on_event_message method signature for state management page (fix #2951)
1 parent cf0b304 commit c8f819b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/docs/develop/state-management.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ Note that the return type must be [`Result`] if you use asynchronous commands.
126126
Sometimes you may need to access the state outside of commands, such as in a different thread or in an event handler like `on_window_event`. In such cases, you can use the `state()` method of types that implement the [`Manager`] trait (such as the `AppHandle`) to get the state:
127127

128128
```rust
129-
use tauri::{Builder, GlobalWindowEvent, Manager};
129+
use tauri::{Builder, Window, WindowEvent, Manager};
130130

131131
#[derive(Default)]
132132
struct AppState {
133133
counter: u32,
134134
}
135135

136136
// In an event handler:
137-
fn on_window_event(event: GlobalWindowEvent) {
137+
fn on_window_event(window: &Window, _event: &WindowEvent) {
138138
// Get a handle to the app so we can get the global state.
139-
let app_handle = event.window().app_handle();
139+
let app_handle = window.app_handle();
140140
let state = app_handle.state::<Mutex<AppState>>();
141141

142142
// Lock the mutex to mutably access the state.

0 commit comments

Comments
 (0)