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) checkViewsForPreventUnload(views) → {Promise.<ViewStatuses>}

It takes in an array of Views and returns an object specifying which of them are trying to prevent an unload and which are not.

Parameters:
Name Type Description
views Array.<View>

Array of Views

Returns:
Type
Promise.<ViewStatuses>

(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) closeWindow(payload, callerIdentity) → {Promise.<void>}

Closes a Window. By default it will fire any before unload handler set by a View in the Window. This can be disabled by setting skipBeforeUnload in the options object of the payload. This method is called by Platform.closeWindow.

Parameters:
Name Type Description
payload CloseWindowPayload

Object that contains the Window Identity and related options.

callerIdentity Identity
Tutorials:
Returns:
Type
Promise.<void>

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

Creates a new view and attaches it to a specified target window, or creates a new window for it if no target window is provided.

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) fetchManifest(payload, callerIdentity)

Handles requests to fetch manifests in the current platform.

Parameters:
Name Type Description
payload FetchManifestPayload

Payload containing the manifestUrl to be fetched.

callerIdentity Identity

If Platform.fetchManifest was called, the identity of the caller will be here. If fetchManifest was called internally, 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) getUserDecisionForBeforeUnload(payload) → {Promise.<BeforeUnloadUserDecision>}

Handle the decision of whether a Window or specific View should close when trying to prevent an unload. This is meant to be overridden. Called in PlatformProvider.closeWindow. Normally you would use this method to show a dialog indicating that there are Views that are trying to prevent an unload. By default, it will return an object that places all passed-in Views in the viewsToClose array. .

Parameters:
Name Type Description
payload ViewsPreventingUnloadPayload
Tutorials:
Returns:
Type
Promise.<BeforeUnloadUserDecision>

(async) getViewsForWindowClose(winId) → {Promise.<View>}

Gets all the Views attached to a Window that should close along with it. This is meant to be overridable in the case where you want to return other Views that may not be attached to the Window that is closing.

Parameters:
Name Type Description
winId

Identity of the Window that is closing

Returns:
Type
Promise.<View>

(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) handleViewsAndWindowClose(winId, userDecision) → {Promise.<void>}

Handles the closing of a Window and/or its Views. Called in PlatformProvider.closeWindow. The return of PlatformProvider.getUserDecisionForBeforeUnload is passed into this method.

Parameters:
Name Type Description
winId Identity

Identity of the Window

userDecision BeforeUnloadUserDecision

Decision object

Returns:
Type
Promise.<void>

(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>