Function tauri_wasm::api::event::listen
source · pub async fn listen<T>(event: &str) -> Result<impl Stream<Item = Event<T>>>where
T: DeserializeOwned + 'static,
Expand description
Listen to an event from the backend.
The returned Future will automatically clean up it’s underlying event listener when dropped, so no manual unlisten function needs to be called.
§Example
use tauri_wasm::api::event::listen;
use web_sys::console;
let events = listen::<String>("error");
while let Some(event) = events.next().await {
console::log_1(&format!("Got error in window {}, payload: {}", event.window_label, event.payload).into());
}