[bug] emitTo emits everywhere
thewh1teagle opened this issue · 1 comments
thewh1teagle commented
Describe the bug
When using window.__TAURI__.event.emitTo(label, event)
all the webviews receive the event.
Reproduction
- Listen on all windows
window.__TAURI__.event.listen("test", () => console.log('test event invoked'))
- Emit some event to non existed window. or emit to specific window.
window.__TAURI__.event.emitTo('not-exists', 'test')
Notice that all the windows / webviews receive the event...
Expected behavior
It should receive the event only in the specified target label
Full tauri info
output
[✔] Environment
- OS: Mac OS 14.5.0 arm64 (X64)
✔ Xcode Command Line Tools: installed
✔ rustc: 1.79.0 (129f3b996 2024-06-10)
✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 20.15.1
- pnpm: 9.1.0
- npm: 10.7.0
- bun: 1.1.18
[-] Packages
- tauri 🦀: 2.0.4
- tauri-build 🦀: 2.0.1
- wry 🦀: 0.46.1
- tao 🦀: 0.30.3
- @tauri-apps/api : 2.0.2
- @tauri-apps/cli : 2.0.3
[-] Plugins
- tauri-plugin-shell 🦀: 2.0.1
- @tauri-apps/plugin-shell : 2.0.0
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- bundler: Vite
Stack trace
No response
Additional context
No response
update
Seems like emitTo
catched by every event.listen
but it won't catch by any if the listen
is called from window.__TAURI__.webview.getCurrentWebview().listen('test', () => console.log('test invoked'))
amrbashir commented
This is the default behavior of listen
from the event
module. It listens on all events unless you specify a target to listen to like this:
listen("event", () => {}, { target: { kind: 'Webview', label: this.label }})
this is how getCurrentWebview().listen()
is implemented