Noteworthy Programming Masterpiece
Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

@vangware/window-open-promise

2.4.3 • Public • Published

@vangware/window-open-promise

NPM Version Build Status

Promised Window.open.

Usage

import windowOpenPromise from "@vangware/window-open-promise";
 
windowOpenPromise()
  .then(newWindow => {
    newWindow.console.log("This will log in the new window.");
    newWindow.addEventListener("beforeunload", event => {
      console.log("This will log when the new window is closed.");
    });
  })
  .catch(error => {
    console.error("This will log if the new window can't be opened.");
  });

Or if you feel you need more sugar:

import windowOpenPromise from "@vangware/window-open-promise";
 
try {
    const newWindow = await windowOpenPromise()
    newWindow.console.log("This will log in the new window.");
    newWindow.addEventListener("beforeunload", event => {
      console.log("This will log when the new window is closed.");
    });
} catch  {
    console.error("This will log if the new window can't be opened.");
}

Install

npm i @vangware/window-open-promise

DownloadsWeekly Downloads

194

Version

2.4.3

License

MIT

Unpacked Size

16.1 kB

Total Files

28

Last publish

Collaborators

  • avatar