1

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
);
glennsl
  • 28,186
  • 12
  • 57
  • 75

1 Answers1

1

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.

glennsl
  • 28,186
  • 12
  • 57
  • 75
  • Note that `Dom` (without `Webapi.` in front) is a module that ships with `bs-platform` that contains most of the types used by `Webapi`. This can be a bit confusing, but we'll hopefully be a bit smarter about naming things in the future. – glennsl Nov 15 '17 at 12:02