Unlisten to an event on this window (#2664)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
ThisSeanZhang
2021-09-28 04:11:23 +08:00
committed by GitHub
parent 4298c0c6bb
commit 3a59f5f79e
2 changed files with 10 additions and 0 deletions

5
.changes/unlisten.md Normal file
View File

@@ -0,0 +1,5 @@
---
"tauri": patch
---
Adds `unlisten` function to the `Window` struct.

View File

@@ -271,6 +271,11 @@ impl<R: Runtime> Window<R> {
self.manager.listen(event.into(), Some(label), handler)
}
/// Unlisten to an event on this window.
pub fn unlisten(&self, handler_id: EventHandler) {
self.manager.unlisten(handler_id)
}
/// Listen to a an event on this window a single time.
pub fn once<F>(&self, event: impl Into<String>, handler: F) -> EventHandler
where