Namespace: Platform

Platform

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.

Namespaces

Layout

Methods

(async, static) getCurrent() → {Promise.<Platform>}

Asynchronously returns a Platform object that represents the current platform.

Tutorials:
Returns:
Type
Promise.<Platform>

(static) getCurrentSync() → {Platform}

Synchronously returns a Platform object that represents the current platform.

Tutorials:
Returns:
Type
Platform

(async, static) init(optionsopt) → {Promise.<void>}

EXPERIMENTAL

Initializes a Platform. Must be called from the Provider when using a custom provider.

Parameters:
Name Type Attributes Description
options InitPlatformOptions <optional>

platform options including a callback function that can be used to extend or replace default Provider behavior.

Tutorials:
Returns:
Type
Promise.<void>

(static) start(platformOptions) → {Promise.<Platform>}

Creates and starts a Platform and returns a wrapped and running Platform instance. The wrapped Platform methods can be used to launch content into the platform. Promise will reject if the platform is already running.

Parameters:
Name Type Description
platformOptions PlatformOptions
Tutorials:
Returns:
Type
Promise.<Platform>

(static) startFromManifest(manifestUrl, optsopt) → {Promise.<Platform>}

Retrieves platforms's manifest and returns a wrapped and running Platform. If there is a snapshot in the manifest, it will be launched into the platform.

Parameters:
Name Type Attributes Description
manifestUrl string

The URL of platform's manifest.

opts RvmLaunchOptions <optional>

Parameters that the RVM will use.

Tutorials:
Returns:
Type
Promise.<Platform>

(async, static) wrap(identity) → {Promise.<Platform>}

Asynchronously returns a Platform object that represents an existing platform.

Parameters:
Name Type Description
identity Identity
Tutorials:
Returns:
Type
Promise.<Platform>

(static) wrapSync(identity) → {Platform}

Synchronously returns a Platform object that represents an existing platform.

Parameters:
Name Type Description
identity Identity
Tutorials:
Returns:
Type
Platform

(async) applySnapshot(requestedSnapshot, optionsopt) → {Promise.<Platform>}

Adds a snapshot to a running Platform.

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:
Name Type Attributes Description
requestedSnapshot Snapshot | string

Snapshot to apply, or a url or filepath.

options ApplySnapshotOptions <optional>

Optional parameters to specify whether existing windows should be closed.

Tutorials:
Returns:
Type
Promise.<Platform>

(async) closeView(viewIdentity) → {Promise.<void>}

Closes a specified view in a target window.

Parameters:
Name Type Description
viewIdentity Identity

View identity

Tutorials:
Returns:
Type
Promise.<void>

(async) createView(viewOptions, targetopt) → {Promise.<View>}

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

Parameters:
Name Type Attributes Description
viewOptions View~options

View creation options

target Identity <optional>

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

Tutorials:
Returns:
Type
Promise.<View>

(async) createWindow(options) → {Promise.<_Window>}

Creates a new Window.

Parameters:
Name Type Description
options Window~options

Window creation options

Tutorials:
Returns:
Type
Promise.<_Window>

(async) getContext() → {Promise.<any>}

EXPERIMENTAL

Get the context of your current window or view environment that was previously set using setContext. The context will be saved in any platform snapshots. Returns a promise that resolves to the context.

Tutorials:
Returns:
Type
Promise.<any>

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

Returns a snapshot of the platform in its current state.

Can be used to restore an application to a previous state.

Tutorials:
Returns:
Type
Promise.<Snapshot>

(async) launchLegacyManifest(manifestUrlopt) → {Promise.<Platform>}

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:
Name Type Attributes Description
manifestUrl string <optional>

The URL of the manifest of the app to launch 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.

Tutorials:
Returns:
Type
Promise.<Platform>

(async) onWindowContextUpdated() → {Promise.<boolean>}

EXPERIMENTAL

Set a listener to be executed when the when a View's target Window experiences a context update. Can only be set from a view that has wrapped it's current platform. The listener receives the new context as its first argument and the previously context as the second argument. If the listener returns a truthy value, the View's context will be updated with the new context as if setContext was called. This can only be set once per javascript environment (once per View), and any subsequent calls to onWindowContextUpdated will error out. If the listener is successfully set, returns a promise that resolves to true.

Tutorials:
Returns:
Type
Promise.<boolean>

(async) quit() → {Promise.<void>}

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

Tutorials:
Returns:
Type
Promise.<void>

(async) reparentView(viewIdentity, target) → {Promise.<View>}

Reparents a specified view in a new target window.

Parameters:
Name Type Description
viewIdentity Identity

View identity

target Identity

new owner window identity

Tutorials:
Returns:
Type
Promise.<View>

(async) setContext(context) → {Promise.<void>}

EXPERIMENTAL

Set the context of your current window or view environment. The context will be saved in any platform snapshots.

Parameters:
Name Type Description
context any

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

Tutorials:
Returns:
Type
Promise.<void>