Skip to content

src/preload/index.ts off方法无效 #216

@howthenowyo

Description

@howthenowyo

Describe the bug

使用window.mainApi.off取消监听时,无法正确取消
window.mainApi.on(.off)经过桥接后,传入的listener方法会被代理为本地方法,导致使用window.mainApi.off和window.mainApi.on时,两个listener的引用不一致,.off无法取消监听。
可以考虑在on方法里面返回取消注册方法return ()=>rpcRenderer.off(channel, listener),将off方法改为取消channel的所有监听

Expected behavior

No response

Your environment - System OS

No response

Your environment - Web Browser

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions