소스 검색

Unlisten to an event on this window (#2664)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
ThisSeanZhang 3 년 전
부모
커밋
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