Просмотр исходного кода

Unlisten to an event on this window (#2664)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
ThisSeanZhang 3 лет назад
Родитель
Сommit
3a59f5f79e
2 измененных файлов с 10 добавлено и 0 удалено
  1. 5 0
      .changes/unlisten.md
  2. 5 0
      core/tauri/src/window.rs

+ 5 - 0
.changes/unlisten.md

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

+ 5 - 0
core/tauri/src/window.rs

@@ -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