AboutSupportDeveloper GuideVersion 41.132.100.56

Static namespace for OpenFin API methods that interact with the Platform class, available under fin.Platform.

Hierarchy

  • Base
    • PlatformModule

Properties

Layout: LayoutModule

Accessors

  • get me(): Identity
  • Returns Identity

    me should only be accessed from the fin global (FinApi.me); access through entity classes is not guaranteed to behave sensibly in all calling contexts.

Methods

  • Asynchronously returns a Platform object that represents the current platform.

    Returns Promise<Platform>

    const platform = await fin.Platform.getCurrent();
    // Use wrapped instance to control layout, e.g.:
    const snapshot = await platform.getSnapshot();
  • Synchronously returns a Platform object that represents the current platform.

    Returns Platform

    const platform = fin.Platform.getCurrentSync();
    // Use wrapped instance to control layout, e.g.:
    const snapshot = await platform.getSnapshot();
  • Experimental

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

    Parameters

    • Optionaloptions: InitPlatformOptions

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

    Returns Promise<void>

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

    // From Provider context
    await fin.Platform.init();
    // Platform API is now hooked up and windows contained in the manifest snapshot are open.

    Platform.init accepts an options object that can contain a callback function which can be used to extend or replace default Provider behavior. As an argument, this function will receive the Provider class, which is used to handle Platform actions. The function must return an object with methods to handle Platform API actions. The recommended approach is to extend the Provider class, overriding the methods you wish to alter, and return an instance of your subclass:

    const overrideCallback = async (PlatformProvider) => {
    // Actions can be performed before initialization.
    // e.g. we might authenticate a user, set up a Channel, etc before initializing the Platform.
    const { manifestUrl } = await fin.Application.getCurrentSync().getInfo();

    // Extend or replace default PlatformProvider behavior by extending the PlatformProvider class.
    class MyOverride extends PlatformProvider {
    // Default behavior can be changed by implementing methods with the same names as those used by the default PlatformProvider.
    async getSnapshot() {
    // Since we are extending the class, we can call `super` methods to access default behavior.
    const snapshot = await super.getSnapshot();
    // But we can modify return values.
    return { ...snapshot, answer: 42, manifestUrl };
    }
    async replaceLayout({ opts, target }) {
    // To disable an API method, overwrite with a noop function.
    return;
    }
    }
    // Return instance with methods to be consumed by Platform.
    // The returned object must implement all methods of the PlatformProvider class.
    // By extending the class, we can simply inherit methods we do not wish to alter.
    return new MyOverride();
    };

    fin.Platform.init({overrideCallback});
  • 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

    Returns Promise<Platform>

    try {
    const platform = await fin.Platform.start({
    uuid: 'platform-1',
    autoShow: false,
    defaultWindowOptions: {
    stylesheetUrl: 'css-sheet-url',
    cornerRounding: {
    height: 10,
    width: 10
    }
    }
    });
    console.log('Platform is running', platform);
    } catch(e) {
    console.error(e);
    }
  • 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

    • manifestUrl: string

      The URL of platform's manifest.

    • Optionalopts: RvmLaunchOptions

      Parameters that the RVM will use.

    Returns Promise<Platform>

    try {
    const platform = await fin.Platform.startFromManifest('https://openfin.github.io/golden-prototype/public.json');
    console.log('Platform is running, wrapped platform: ', platform);
    } catch(e) {
    console.error(e);
    }
    // For a local manifest file:
    try {
    const platform = await fin.Platform.startFromManifest('file:///C:/somefolder/app.json');
    console.log('Platform is running, wrapped platform: ', platform);
    } catch(e) {
    console.error(e);
    }
  • Asynchronously returns a Platform object that represents an existing platform.

    Parameters

    Returns Promise<Platform>

    const { identity } = fin.me;
    const platform = await fin.Platform.wrap(identity);
    // Use wrapped instance to control layout, e.g.:
    const snapshot = await platform.getSnapshot();
  • Synchronously returns a Platform object that represents an existing platform.

    Parameters

    Returns Platform

    const { identity } = fin.me;
    const platform = fin.Platform.wrapSync(identity);
    // Use wrapped instance to control layout, e.g.:
    const snapshot = await platform.getSnapshot();