Skip to content

Make phxWindow.addEventListener optional #6198

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

majeed-platogo
Copy link

The block below is useful for handling autoconnection/disconnection when users leave or enter the tab

if (phxWindow && phxWindow.addEventListener) {
      phxWindow.addEventListener("pagehide", (_e) => {
        if (this.conn) {
          this.disconnect();
          awaitingConnectionOnPageShow = this.connectClock;
        }
      });
      phxWindow.addEventListener("pageshow", (_e) => {
        if (awaitingConnectionOnPageShow === this.connectClock) {
          awaitingConnectionOnPageShow = null;
          this.connect();
        }
      });
    }

But in our case, It clashes with our own listener that does this among other things. That's why we're introducing disableWindowEventListeners to make this optional

Co-authored-by: Tomislav Markanovic <tomislav@platogo.com>
@majeed-platogo majeed-platogo force-pushed the change/optional-window-event-listeners branch from f0d39f0 to 82e69d7 Compare April 16, 2025 11:43
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

Successfully merging this pull request may close these issues.

1 participant