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

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

Handles requests to apply a snapshot to the current Platform.

Parameters:
Name Type Description
payload ApplySnapshotPayload

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

callerIdentity Identity

Identity of the entity that called Platform.applySnapshot. If called internally (e.g. when opening the initial snapshot), callerIdentity will be the identity of the provider.

Tutorials:
Returns:
Type
Promise.<void>

(async) closeView(payload, callerIdentity)

Closes a view

Parameters:
Name Type Description
payload CloseViewPayload

Specifies the target view to be closed.

callerIdentity Identity

Identity of the entity that called Platform.closeView.

Tutorials:

(async) createView(payload, callerIdentity) → {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.

callerIdentity Identity

Identity of the entity that called Platform.createView.

Returns:
Type
Promise.<void>

(async) createWindow(payload, callerIdentity)

Handles requests to create a window in the current platform.

Parameters:
Name Type Description
payload WindowOption

Window options for the window to be created.

callerIdentity Identity

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, callerIdentity will be the provider's identity.

Tutorials:

(async) getSnapshot(payload, callerIdentity) → {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.

callerIdentity Identity

Identity of the entity that called Platform.getSnapshot.

Tutorials:
Returns:

Snapshot of current platform state.

Type
Promise.<Snapshot>

(async) getWindowContext(payload, callerIdentity) → {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 Description
payload GetWindowContextPayload

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

callerIdentity Identity

Identity of the entity that called Platform.getWindowContext. If 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), callerIdentity will be the provider's identity.

Tutorials:
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.

Tutorials:
Returns:

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

Type
Promise.<Array.<WindowOptions>>

quit(payload, callerIdentity) → {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.

callerIdentity Identity

Identity of the entity that called Platform.quit. If called in response to the last window in a platform closing, callerIdentity will be the provider's identity.

Tutorials:
Returns:
Type
Promise.<void>

(async) replaceLayout(payload, callerIdentity) → {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 Description
payload ReplaceLayoutPayload

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

callerIdentity Identity

Identity of the entity that called Platform.replaceLayout. If replaceLayout is called internally (e.g. while applying a snapshot), callerIdentity will be the provider's identity.

Tutorials:
Returns:
Type
Promise.<void>

(async) setWindowContext(payload, callerIdentity) → {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 Description
payload SetWindowContextPayload

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

callerIdentity Identity

Identity of the entity that called Platform.setWindowContext. If setWindowContext is called internally (e.g. while applying a snapshot), callerIdentity will be the provider's identity.

Tutorials:
Returns:

The new context.

Type
Promise.<any>