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

removeAllListeners doesn't seem to remove listeners (NW2) #7593

Closed
DjulLau opened this issue Oct 15, 2020 · 2 comments
Closed

removeAllListeners doesn't seem to remove listeners (NW2) #7593

DjulLau opened this issue Oct 15, 2020 · 2 comments

Comments

@DjulLau
Copy link

DjulLau commented Oct 15, 2020

NWJS Version : 0.49.0
Operating System : Windows 10

I recently tried upgrading my app from v0.28 to v0.49.
In this app I open a second window behind the main window to do some capture.
I listen to the 'loaded' event on the window to wait before doing the capture.
Then I call removeAllListeners('loaded') to stop listening to this event but I still receive the event with new version after that.

Expected behavior

Should not receive 'loaded' event after calling removeAllListeners('loaded')

Actual behavior

'loaded' event still received after calling removeAllListeners('loaded')

How to reproduce

    require("nw.gui").Window.open("new.html", {}, (wnd) => {
        wnd.on("loaded", (e) => {
            console.debug("loaded");
            
            wnd.removeAllListeners("loaded");
            console.debug("new load");
            wnd.window.location.href = "new.html";
        });
    });

Output

loaded
new load
loaded
new load
loaded
new load
loaded
new load
...
  • Add "chromium-args": "--disable-features=nw2"
  • Run again
    Output
loaded
new load

Workaround

Use window.once('loaded') instead of window.on('loaded').

@DjulLau
Copy link
Author

DjulLau commented Oct 15, 2020

CC #7230

@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants