-
Hello, how can I share state between events. Like I want to create in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
With the limited information you've provided, I think the best way to do this would be to use a static Mutex if using a AsyncEventListener, maybe like so. I haven't tested it, but it should compile. use hyprland::event_listener::EventListener;
use std::sync::Mutex;
static TEST_THING: Mutex<Vec<String>> = Mutex::new(Vec::new());
#[tokio::main]
async fn main() -> hyprland::Result<()> {
let mut listener = EventListener::new();
listener.add_workspace_change_handler(move |workspace| {
TEST_THING.lock().unwrap().push(workspace.to_string());
println!("vec: {:?}", TEST_THING);
});
listener.start_listener_async().await?;
Ok(())
} |
Beta Was this translation helpful? Give feedback.
With the limited information you've provided, I think the best way to do this would be to use a static Mutex if using a AsyncEventListener, maybe like so. I haven't tested it, but it should compile.