Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling unlisten from JavaScript removes all listeners #2264

Closed
Florob opened this issue Jul 20, 2021 · 0 comments
Closed

Calling unlisten from JavaScript removes all listeners #2264

Florob opened this issue Jul 20, 2021 · 0 comments

Comments

@Florob
Copy link

Florob commented Jul 20, 2021

Describe the bug

Calling any unlisten() function returned by a listen() call remove all callbacks registered through listen().

To Reproduce

Steps to reproduce the behavior:

  1. Create a new tauri project (or use an existing one)
  2. Add the following code:
import { listen } from "@tauri-apps/api/event";
async function setup() {
  let unlisten = await listen("tauri://blur", () => console.log("blur"));
  await listen("tauri://focus", () => console.log("focus"));;
  await listen("tauri://resize", () => console.log("resize"));;

  unlisten();
}
setup();
  1. Open a console
  2. Resize/focus/blur the window
  3. Observe none of the callbacks are triggered

Expected behavior

Only the callback associated with the unlisten() function should be unregistered.

Platform and Versions (required):

Operating System - Arch Linux, version Rolling Release X64

Node.js environment
  Node.js - 16.5.0
  @tauri-apps/cli - 1.0.0-beta.6
  @tauri-apps/api - 1.0.0-beta.5

Global packages
  npm - 7.17.0
  yarn - 1.22.10

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/node_modules
/src
/src-tauri
/.git

App
  tauri.rs - 1.0.0-beta.5
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant