Skip to content

[bug] Differences in behavior between appWindow.listen() and listen() #4493

@icambron

Description

@icambron

Describe the bug

appWindow.listen() isn't triggered by window.emit_to or window.emit_all calls, whereas listen() is. My conversation on Discord with @FabianLars suggested this wasn't supposed to the case.

Reproduction

Given some JS code like:

import { listen } from "@tauri-apps/api/event";
import { appWindow } from "@tauri-apps/api/window";

listen("foo", e => console.log("foo", e);
appWindow.listen("bar", e => console.log("bar", e));

and Rust like:

window.emit("foo", "payload"); // works
window.emit_to("main", "foo", "payload") // works
window.emit_all("foo", "payload") // works

window.emit("bar", "payload"); //works
window.emit_to("main", "bar", "payload") // does NOT work
window.emit_all("bar", "payload") // does NOT work

Expected behavior

No response

Platform and versions

❯ yarn tauri info                                                                                                                                                                
yarn run v1.22.17                                                                                                                                                                
$ /Users/isaac/code/lqbk/blot3/node_modules/.bin/tauri info                                                                                                                      
                                                                                                                                                                                 
Environment                                                                                                                                                                      
  › OS: Mac OS 12.4.0 X64                                                                                                                                                        
  › Node.js: 18.4.0                                                                                                                                                              
  › npm: 8.12.1                                                                                                                                                                  
  › pnpm: Not installed!                                                                                                                                                         
  › yarn: 1.22.17                                                                                                                                                                
  › rustup: 1.24.3                                                                                                                                                               
  › rustc: 1.61.0                                                                                                                                                                
  › cargo: 1.61.0                                                                                                                                                                
  › Rust toolchain: stable-aarch64-apple-darwin                                                                                                                                  
                                                                                                                                                                                 
Packages                                                                                                                                                                         
  › @tauri-apps/cli [NPM]: 1.0.0                                                                                                                                                 
  › @tauri-apps/api [NPM]: 1.0.1                                                                                                                                                 
  › tauri [RUST]: 1.0.0,                                                                                                                                                         
  › tauri-build [RUST]: 1.0.0,                                                                                                                                                   
  › tao [RUST]: 0.11.2,                                                                                                                                                          
  › wry [RUST]: 0.18.3,                                                                                                                                                          
                                                                                                                                                                                 
App                                                                                                                                                                              
  › build-type: bundle                                                                                                                                                           
  › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: asset: customprotocol: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'                            
  › distDir: ../dist                                                                                                                                                             
  › devPath: http://localhost:3000/                                                                                                                                              
  › framework: React                                                                                                                                                             
                                                                                                                                                                                 
App directory structure                                                                                                                                                          
  ├─ types                                                                                                                                                                       
  ├─ test                                                                                                                                                                        
  ├─ dist                                                                                                                                                                        
  ├─ node_modules                                                                                                                                                                
  ├─ browser                                                                                                                                                                     
  ├─ public                                                                                                                                                                      
  ├─ src-tauri                                                                                                                                                                   
  └─ src                                                                                                                                                                         
✨  Done in 7.08s.  


### Stack trace

_No response_

### Additional context

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions