Add an event listener to the window

104 views Asked by At

I am trying to add an event listener to the window, but I am unsure how to get the window.

I currently have this.

let onUnhandledRejection = (e) => {
  /* TODO: write this */
}

WindowRe.addEventListener(
  "unhandledrejection",
  onUnhandledRejection,
  WINDOW_GOES_HERE: Dom.window
);
1

There are 1 answers

1
InsidersByte On

The current window object is available as Webapi.Dom.window

let onUnhandledRejection = (e) => {
  /* TODO: write this */
}

Webapi.Dom.Window.addEventListener(
  "unhandledrejection",
  onUnhandledRejection,
  Webapi.Dom.window
);

You also shouldn't use WindowRe as it's a private API.