• Promised Window.open.

    Example

    const windowOpen = windowOpenPromise(window);
    windowOpen({
    url: "https://example.com",
    top: 10,
    left: 10
    })
    .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.");
    });

    Returns

    Curried function with window in context.

    Parameters

    • window: Readonly<Pick<Window, "open">>

      Window object (or maybe a mock :D).

    Returns ((options?: WindowOpenPromiseOptions) => Promise<Window>)

      • (options?: WindowOpenPromiseOptions): Promise<Window>
      • Curried function with window set.

        Example

        const windowOpen = windowOpenPromise(window);
        windowOpen({
        url: "https://example.com",
        top: 10,
        left: 10
        })
        .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.");
        });

        Returns

        Promise with new window.

        Parameters

        Returns Promise<Window>