AboutSupportDeveloper GuideVersion 37.124.81.30

Manages the life cycle of windows and views in the application.

Enables taking snapshots of itself and applying them to restore a previous configuration as well as listen to platform events.

Hierarchy

Properties

Application: Application
Layout: LayoutModule

Accessors

  • get me(): Identity
  • Provides access to the OpenFin representation of the current code context (usually a document such as a View or Window), as well as to the current Interop context.

    Useful for debugging in the devtools console, where this will intelligently type itself based on the context in which the devtools panel was opened.

    Returns Identity

Methods

  • Adds a listener to the end of the listeners array for the specified event.

    Type Parameters

    • EventType extends "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Parameters

    Returns Promise<Platform>

  • Adds a snapshot to a running Platform. Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.

    Can optionally close existing windows and overwrite current platform state with that of a snapshot.

    The function accepts either a snapshot taken using getSnapshot, or a url or filepath to a snapshot JSON object.

    Parameters

    • requestedSnapshot: string | Snapshot

      Snapshot to apply, or a url or filepath.

    • Optional options: ApplySnapshotOptions

      Optional parameters to specify whether existing windows should be closed.

    Returns Promise<Platform>

    Remarks

    Will create any windows and views that are not running but are passed in the snapshot object. Any View specified in the snapshot is assigned a randomly generated name to avoid collisions.

    Example

    // Get a wrapped layout platform instance
    const platform = await fin.Platform.getCurrent();

    const snapshot = {
    windows: [
    {
    layout: {
    content: [
    {
    type: 'stack',
    content: [
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'component_X',
    url: 'https://www.openfin.co'
    }
    },
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'component_Y',
    url: 'https://cdn.openfin.co/embed-web/chart.html'
    }
    }
    ]
    }
    ]
    }
    }
    ]
    }

    platform.applySnapshot(snapshot);

    In place of a snapshot object, applySnapshot can take a url or filepath and to retrieve a JSON snapshot.

    const platform = await fin.Platform.getCurrent();
    platform.applySnapshot('https://api.jsonbin.io/b/5e6f903ef4331e681fc1231d/1');

    Optionally, applySnapshot can close existing windows and restore a Platform to a previously saved state. This is accomplished by providing { closeExistingWindows: true } as an option.

    // Get a wrapped layout platform instance
    const platform = await fin.Platform.getCurrent();

    async function addViewToWindow(winId) {
    return await platform.createView({
    name: 'test_view_3',
    url: 'https://openfin.co'
    }, winId);
    }

    async function createWindowWithTwoViews() {
    const platform = await fin.Platform.getCurrent();

    return platform.createWindow({
    layout: {
    content: [
    {
    type: 'stack',
    content: [
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'test_view_1',
    url: 'https://example.com'
    }
    },
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'test_view_2',
    url: 'https://yahoo.com'
    }
    }
    ]
    }
    ]
    }
    });
    }

    const win = await createWindowWithTwoViews();
    // ... you will now see a new window with two views in it

    // we take a snapshot of the current state of the app, before changing it
    const snapshotOfInitialAppState = await platform.getSnapshot();

    // now let's change the state of the app:
    await addViewToWindow(win.identity);
    // ... the window now has three views in it

    await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
    // ... the window will revert to previous state, with just two views
  • Closes a specified view in a target window.

    Parameters

    Returns Promise<void>

    Example

    let windowIdentity;
    if (fin.me.isWindow) {
    windowIdentity = fin.me.identity;
    } else if (fin.me.isView) {
    windowIdentity = (await fin.me.getCurrentWindow()).identity;
    } else {
    throw new Error('Not running in a platform View or Window');
    }

    const viewOptions = {
    name: 'test_view',
    url: 'https://example.com'
    };

    function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
    }

    const platform = await fin.Platform.getCurrent();

    await platform.createView(viewOptions, windowIdentity);
    // a new view will now show in the current window

    await sleep(5000);

    const viewIdentity = { uuid: windowIdentity.uuid, name: 'test_view'};
    platform.closeView(viewIdentity);
    // the view will now close
  • Experimental

    Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.

    Parameters

    • windowId: Identity
    • options: {
          skipBeforeUnload: boolean;
      } = ...
      • skipBeforeUnload: boolean

    Returns Promise<void>

    Remarks

    This method works by setting a close-requested handler on the Platform Window. If you have your own close-requested handler set on the Platform Window as well, it is recommended to move that logic over to the [PlatformProvider.closeWindow]closeWindow override to ensure it runs when the Window closes.

    Example

    // Close the current Window inside a Window context
    const platform = await fin.Platform.getCurrent();
    platform.closeWindow(fin.me.identity);

    // Close the Window from inside a View context
    const platform = await fin.Platform.getCurrent();
    const parentWindow = await fin.me.getCurrentWindow();
    platform.closeWindow(parentWindow.identity);

    // Close the Window and do not fire the before unload handler on Views
    const platform = await fin.Platform.getCurrent();
    platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
  • Creates a new view and attaches it to a specified target window.

    Parameters

    • viewOptions: Partial<ViewOptions>

      View creation options

    • Optional target: CreateViewTarget

      The window to which the new view is to be attached. If no target, create a view in a new window.

    • Optional targetView: Identity

      If provided, the new view will be added to the same tabstrip as targetView.

    Returns Promise<View>

    Remarks

    If the view already exists, will reparent the view to the new target. You do not need to set a name for a View. Views that are not passed a name get a randomly generated one.

    Example

    let windowIdentity;
    if (fin.me.isWindow) {
    windowIdentity = fin.me.identity;
    } else if (fin.me.isView) {
    windowIdentity = (await fin.me.getCurrentWindow()).identity;
    } else {
    throw new Error('Not running in a platform View or Window');
    }

    const platform = fin.Platform.getCurrentSync();

    platform.createView({
    name: 'test_view',
    url: 'https://developers.openfin.co/docs/platform-api'
    }, windowIdentity).then(console.log);

    Reparenting a view:

    let windowIdentity;
    if (fin.me.isWindow) {
    windowIdentity = fin.me.identity;
    } else if (fin.me.isView) {
    windowIdentity = (await fin.me.getCurrentWindow()).identity;
    } else {
    throw new Error('Not running in a platform View or Window');
    }

    let platform = fin.Platform.getCurrentSync();
    let viewOptions = {
    name: 'example_view',
    url: 'https://example.com'
    };
    // a new view will now show in the current window
    await platform.createView(viewOptions, windowIdentity);

    const view = fin.View.wrapSync({ uuid: windowIdentity.uuid, name: 'yahoo_view' });
    // reparent `example_view` when a view in the new window is shown
    view.on('shown', async () => {
    let viewIdentity = { uuid: windowIdentity.uuid, name: 'example_view'};
    let target = {uuid: windowIdentity.uuid, name: 'test_win'};
    platform.createView(viewOptions, target);
    });

    // create a new window
    await platform.createWindow({
    name: "test_win",
    layout: {
    content: [
    {
    type: 'stack',
    content: [
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'yahoo_view',
    url: 'https://yahoo.com'
    }
    }
    ]
    }
    ]
    }
    }).then(console.log);
  • Creates a new Window.

    Parameters

    Returns Promise<Window & Identity>

    Remarks

    There are two Window types at your disposal while using OpenFin Platforms - Default Window and Custom Window.

    The Default Window uses the standard OpenFin Window UI. It contains the standard close, maximize and minimize buttons, and will automatically render the Window's layout if one is specified.

    For deeper customization, you can bring your own Window code into a Platform. This is called a Custom Window.

    Example

    The example below will create a Default Window which uses OpenFin default Window UI.
    The Window contains two Views in a stack Layout:

    const platform = fin.Platform.getCurrentSync();
    platform.createWindow({
    layout: {
    content: [
    {
    type: 'stack',
    content: [
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'test_view_1',
    url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
    }
    },
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'test_view_2',
    url: 'https://cdn.openfin.co/docs/javascript/canary/Platform.html'
    }
    }
    ]
    }
    ]
    }
    }).then(console.log);

    The Default Window's design can be customized by specifying the stylesheetUrl property in the manifest:

    {
    platform: {
    defaultWindowOptions: {
    stylesheetUrl: 'some-url.css',
    ...
    }
    }
    }

    For a list of common Layout CSS classes you can override in your custom stylesheet, see Useful Layout CSS Classes * To specify a Platform Custom Window, provide a url property when creating a Window. If you intend to render a Layout in your Custom Window, you must also specify an HTMLElement that the Layout will inject into and set its id property to "layout-container".

    The example below will create a Platform Custom Window:

        // in an OpenFin app:
    const platform = fin.Platform.getCurrentSync();
    const windowConfig =
    {
    url: "https://www.my-domain.com/my-custom-window.html", // here we point to where the Custom Frame is hosted.
    layout: {
    content: [
    {
    type: "stack",
    content: [
    {
    type: "component",
    componentName: "view",
    componentState: {
    name: "app #1",
    url: "https://cdn.openfin.co/docs/javascript/canary/Platform.html"
    }
    },
    {
    type: "component",
    componentName: "view",
    componentState: {
    name: "app #2",
    url: "https://cdn.openfin.co/docs/javascript/canary/Platform.html"
    }
    }
    ]
    }
    ]
    }
    };
    platform.createWindow(windowConfig);

    Here's an example of a minimalist Custom Platform Window implementation:

    <html>
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="./styles.css">
    </head>
    <body>
    <div id="of-frame-main">
    <div id="title-bar">
    <div class="title-bar-draggable">
    <div id="title"> This is a custom frame! </div>
    </div>
    <div id="buttons-wrapper">
    <div class="button" id="minimize-button"></div>
    <div class="button" id="expand-button"></div>
    <div class="button" id="close-button"></div>
    </div>
    </div>
    <div id="layout-container"></div> <!-- OpenFin layout would be injected here -->
    <script src="./custom-frame.js"></script>
    </div>
    </body>
    </html>

    Your Custom Window can use in-domain resources for further customization (such as CSS, scripts, etc.).
    For a list of common Layout CSS classes you can override in your stylesheet, see Useful Layout CSS Classes

    The example above will require the body element to have height: 100%; set in order to render the layout correctly.

  • Returns (string | symbol)[]

  • Fetches a JSON manifest using the browser process and returns a Javascript object. Can be overwritten using Platform.init.

    Parameters

    • manifestUrl: string

      The URL of the manifest to fetch.

    Returns Promise<any>

    Remarks

    Can be overwritten using Platform#init Platform.init.

    Example

    const platform = fin.Platform.getCurrentSync();
    const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
    console.log(manifest);
  • Returns a snapshot of the platform in its current state. You can pass the returning object to [Platform.applySnapshot]applySnapshot to launch it.

    Returns Promise<Snapshot>

    Remarks

    The snapshot will include details such as an ISO format timestamp of when the snapshot was taken, OpenFin runtime version the platform is running on, monitor information and the list of currently running windows.

    Example

    const platform = await fin.Platform.getCurrent();
    const snapshot = await platform.getSnapshot();
  • Experimental

    Get the context context of a host window that was previously set using setWindowContext. The context will be saved in any platform snapshots. Returns a promise that resolves to the context.

    Parameters

    • Optional target: Identity

      A target window or view may optionally be provided. If no target is provided, target will be the current window (if called from a Window) or the current host window (if called from a View).

    Returns Promise<any>

    Remarks

    This method can be called from the window itself, or from any child view. Context data is shared by all entities within a window.

    Example

    Retrieving context from current window:

    const platform = fin.Platform.getCurrentSync();
    const customContext = { answer: 42 };
    await platform.setWindowContext(customContext);

    const myContext = await platform.getWindowContext();
    console.log(myContext); // { answer: 42 }

    Retrieving the context of another window or view:

    const platform = fin.Platform.getCurrentSync();

    const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };

    const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
    console.log(targetWindowContext); // context of target window
  • Experimental

    Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that resolves to the wrapped Platform.

    Parameters

    • manifestUrl: string

      The URL of the manifest that will be launched into the platform. If this app manifest contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options will be launched into the platform. The applicable startup_app options will become View Options.

    Returns Promise<Platform>

    Remarks

    If the app manifest contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options will be launched into the platform as a window with a single view. The applicable startup_app options will become View Options.

    Example

    try {
    const platform = fin.Platform.getCurrentSync();
    await platform.launchContentManifest('http://localhost:5555/app.json');
    console.log(`content launched successfully into platform`);
    } catch(e) {
    console.error(e);
    }
    // For a local manifest file:
    try {
    const platform = fin.Platform.getCurrentSync();
    platform.launchContentManifest('file:///C:/somefolder/app.json');
    console.log(`content launched successfully into platform`);
    } catch(e) {
    console.error(e);
    }
  • Parameters

    • type: string | symbol

    Returns number

  • Parameters

    • type: string | symbol

    Returns Function[]

  • Adds a listener to the end of the listeners array for the specified event.

    Type Parameters

    • EventType extends "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Parameters

    Returns Promise<Platform>

    Remarks

    Event payloads are documented in the Events namespace.

  • Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.

    Type Parameters

    • EventType extends "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Parameters

    Returns Promise<Platform>

    Remarks

    Event payloads are documented in the Events namespace.

  • Adds a listener to the beginning of the listeners array for the specified event.

    Type Parameters

    • EventType extends "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Parameters

    Returns Promise<Platform>

    Remarks

    Event payloads are documented in the Events namespace.

  • Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed. The listener is added to the beginning of the listeners array.

    Type Parameters

    • EventType extends "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Parameters

    Returns Promise<Platform>

    Remarks

    Event payloads are documented in the Events namespace.

  • Closes current platform, all its windows, and their views.

    Returns Promise<void>

    Example

    const platform = await fin.Platform.getCurrent();
    platform.quit();
    // All windows/views in current layout platform will close and platform will shut down
  • Removes all listeners, or those of the specified event.

    Parameters

    • Optional eventType: "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Returns Promise<Platform>

  • Remove a listener from the listener array for the specified event.

    Type Parameters

    • EventType extends "crashed" | "started" | "closed" | "initialized" | "view-blurred" | "view-certificate-selection-shown" | "view-crashed" | "view-did-change-theme-color" | "view-focused" | "view-navigation-rejected" | "view-url-changed" | "view-did-fail-load" | "view-did-finish-load" | "view-page-favicon-updated" | "view-page-title-updated" | "view-resource-load-failed" | "view-resource-response-received" | "view-child-content-blocked" | "view-child-content-opened-in-browser" | "view-child-view-created" | "view-child-window-created" | "view-file-download-started" | "view-file-download-progress" | "view-file-download-completed" | "view-found-in-page" | "view-certificate-error" | "view-content-blocked" | "view-will-redirect" | "view-created" | "view-destroyed" | "view-hidden" | "view-hotkey" | "view-shown" | "view-target-changed" | "view-host-context-changed" | "connected" | "window-alert-requested" | "window-created" | "window-end-load" | "window-not-responding" | "window-responding" | "window-start-load" | "manifest-changed" | "not-responding" | "responding" | "run-requested" | "tray-icon-clicked" | "file-download-location-changed" | "platform-api-ready" | "platform-snapshot-applied" | "window-blurred" | "window-certificate-selection-shown" | "window-crashed" | "window-did-change-theme-color" | "window-focused" | "window-navigation-rejected" | "window-url-changed" | "window-did-fail-load" | "window-did-finish-load" | "window-page-favicon-updated" | "window-page-title-updated" | "window-resource-load-failed" | "window-resource-response-received" | "window-child-content-blocked" | "window-child-content-opened-in-browser" | "window-child-view-created" | "window-child-window-created" | "window-file-download-started" | "window-file-download-progress" | "window-file-download-completed" | "window-found-in-page" | "window-certificate-error" | "window-content-blocked" | "window-will-redirect" | "window-view-attached" | "window-view-detached" | "window-auth-requested" | "window-begin-user-bounds-changing" | "window-bounds-changed" | "window-bounds-changing" | "window-context-changed" | "window-closed" | "window-closing" | "window-disabled-movement-bounds-changed" | "window-disabled-movement-bounds-changing" | "window-embedded" | "window-end-user-bounds-changing" | "window-external-process-exited" | "window-external-process-started" | "window-hidden" | "window-hotkey" | "window-initialized" | "window-layout-initialized" | "window-layout-ready" | "window-maximized" | "window-minimized" | "window-options-changed" | "window-performance-report" | "window-preload-scripts-state-changed" | "window-preload-scripts-state-changing" | "window-reloaded" | "window-restored" | "window-show-requested" | "window-shown" | "window-user-movement-disabled" | "window-user-movement-enabled" | "window-will-move" | "window-will-resize" | "window-show-all-downloads" | "window-download-shelf-visibility-changed"

    Parameters

    Returns Promise<Platform>

    Remarks

    Caution: Calling this method changes the array indices in the listener array behind the listener.

  • DEPRECATED - please use Platform.createView. Reparents a specified view in a new target window.

    Parameters

    • viewIdentity: Identity

      View identity

    • target: Identity

      new owner window identity

    Returns Promise<View>

  • Experimental

    Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots. It can be retrieved using getWindowContext.

    Parameters

    • context: any = {}

      A field where serializable context data can be stored to be saved in platform snapshots.

    • Optional target: Identity

      A target window or view may optionally be provided. If no target is provided, the update will be applied to the current window (if called from a Window) or the current host window (if called from a View).

    Returns Promise<void>

    Remarks

    The context data must be serializable. This can only be called from a window or view that has been launched into a platform. This method can be called from the window itself, or from any child view. Context data is shared by all entities within a window.

    Example

    Setting own context:

    const platform = fin.Platform.getCurrentSync();
    const contextData = {
    security: 'STOCK',
    currentView: 'detailed'
    }

    await platform.setWindowContext(contextData);
    // Context of current window is now set to `contextData`

    Setting the context of another window or view:

    const platform = fin.Platform.getCurrentSync();
    const contextData = {
    security: 'STOCK',
    currentView: 'detailed'
    }

    const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
    await platform.setWindowContext(contextData, windowOrViewIdentity);
    // Context of the target window or view is now set to `contextData`

    A view can listen to changes to its host window's context by listening to the host-context-changed event. This event will fire when a host window's context is updated or when the view is reparented to a new window:

    // From a view
    const contextChangeHandler = ({ context }) => {
    console.log('Host window\'s context has changed. New context data:', context);
    // react to new context data here
    }
    await fin.me.on('host-context-changed', contextChangeHandler);

    const platform = await fin.Platform.getCurrentSync();
    const contextData = {
    security: 'STOCK',
    currentView: 'detailed'
    }
    platform.setWindowContext(contextData) // contextChangeHandler will log the new context

    To listen to a window's context updates, use the context-changed event:

    // From a window
    const contextChangeHandler = ({ context }) => {
    console.log('This window\'s context has changed. New context data:', context);
    // react to new context data here
    }
    await fin.me.on('context-changed', contextChangeHandler);

    const platform = await fin.Platform.getCurrentSync();
    const contextData = {
    security: 'STOCK',
    currentView: 'detailed'
    }
    platform.setWindowContext(contextData) // contextChangeHandler will log the new context