Class: PlatformProvider

PlatformProvider

This class handles Platform actions. It does not need to be used directly by developers. However, its methods can be overriden by passing an overrideCallback to Platform.init in order to implement custom Platform behavior. (See Platform.init)

For an overview of Provider customization, see https://developers.openfin.co/docs/platform-customization#section-customizing-platform-behavior.

Methods

addView(payload, identity) → {Promise.<void>}

Add a view to the target window. If the view does not exist yet, it will be created.

Parameters:
Name Type Description
payload CreateViewPayload

Contains two properties: opts, the view creation options, and target, the window to append the view to.

identity Identity

Identity of the entity that called Platform.addView. Undefined if addView is called internally (e.g. as part of createView).

Returns:
Type
Promise.<void>

(async) applySnapshot(payload, identityopt) → {Promise.<void>}

Handles requests to apply a snapshot to the current Platform.

Parameters:
Name Type Attributes Description
payload ApplySnapshotPayload

Payload containing the snapshot to be applied, as well as any options.

identity Identity <optional>

Identity of the entity that called Platform.applySnapshot. Undefined if called internally (e.g. when opening the initial snapshot).

Returns:
Type
Promise.<void>

(async) closeView(payload, identity)

Closes a view

Parameters:
Name Type Description
payload CloseViewPayload

Specifies the target view to be closed.

identity Identity

Identity of the entity that called Platform.closeView.

createView(payload, identity) → {Promise.<void>}

Creates a new view and attaches it to a specified target window.

Parameters:
Name Type Description
payload CreateViewPayload

Creation options for the new view.

identity Identity

Identity of the entity that called Platform.createView.

Returns:
Type
Promise.<void>

(async) createWindow(payload, identityopt)

Handles requests to create a window in the current platform.

Parameters:
Name Type Attributes Description
payload WindowOption

Window options for the window to be created.

identity Identity <optional>

If Platform.createWindow was called, the identity of the caller will be here. If createWindow was called as part of applying a snapshot or creating a view without a target window, identity will be undefined.

(async) getSnapshot(payload, identity) → {Promise.<Snapshot>}

Gets the current state of windows and their views and returns a snapshot object containing that info.

Parameters:
Name Type Description
payload undefined

Undefined unless you've defined a custom getSnapshot protocol.

identity Identity

Identity of the entity that called Platform.getSnapshot.

Returns:

Snapshot of current platform state.

Type
Promise.<Snapshot>

(async) getWindowContext(payload, identityopt) → {Promise.<any>}

Handles requests to get a window's context. target may be a window or a view. If it is a window, that window's customContext will be returned. If it is a view, the customContext of that view's current host window will be returned.

Parameters:
Name Type Attributes Description
payload GetWindowContextPayload

Object containing the requested context update, the target's identity, and the target's entityType.

identity Identity <optional>

Identity of the entity that called Platform.getWindowContext. Undefined when getWindowContext is called internally (e.g. when getting a window's context for the purpose of raising a "host-context-changed" event on a reparented view).

Returns:

The new context.

Type
Promise.<any>

(async) onWindowContextUpdated(payload) → {Promise.<HostContextChangedPayload>}

Called when a window's customContext is updated. Responsible for raising the host-context-updated event on that window's child views.

Parameters:
Name Type Description
payload WindowOptionsChangedEvent.<'window', 'options-changed'>

The event payload for the window whose context has changed. The new context will be contained as payload.diff.customContext.newVal.

Returns:

The event that it raised.

Type
Promise.<HostContextChangedPayload>

(async) positionOutOfBoundsWindows(snapshot, outOfBoundsWindows) → {Promise.<Array.<WindowOptions>>}

Called when a snapshot is being applied and some windows in that snapshot would be fully or partially off-screen. Returns an array of windows with modified positions, such that any off-screen windows are positioned in the top left corner of the main monitor.

Parameters:
Name Type Description
snapshot Snapshot

The snapshot to be applied.

outOfBoundsWindows Array.<WindowOptions>

An array of WindowOptions for any windows that would be off-screen.

Returns:

An array of WindowOptions with their position modified to fit on screen.

Type
Promise.<Array.<WindowOptions>>

quit(payload, identity) → {Promise.<void>}

Closes the current Platform and all child windows and views.

Parameters:
Name Type Description
payload undefined

Undefined unless you have implemented a custom quite protocol.

identity Identity

Identity of the entity that called Platform.quit.

Returns:
Type
Promise.<void>

(async) replaceLayout(payload, identityopt) → {Promise.<void>}

Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout will be destroyed.

Parameters:
Name Type Attributes Description
payload ReplaceLayoutPayload

Contains the target window and an opts object with a layout property to apply.

identity Identity <optional>

Identity of the entity that called Platform.replaceLayout. Undefined if replaceLayout is called internally (e.g. while applying a snapshot).

Returns:
Type
Promise.<void>

(async) setWindowContext(payload, identityopt) → {Promise.<any>}

Handles requests to set a window's context. target may be a window or a view. If it is a window, that window's customContext will be updated. If it is a view, the customContext of that view's current host window will be updated.

Parameters:
Name Type Attributes Description
payload SetWindowContextPayload

Object containing the requested context update, the target's identity, and the target's entityType.

identity Identity <optional>

Identity of the entity that called Platform.setWindowContext. Undefined if setWindowContext is called internally (e.g. while applying a snapshot).

Returns:

The new context.

Type
Promise.<any>