Skip to content

Commit

Permalink
Merge branch 'main' into workspace/vnext
Browse files Browse the repository at this point in the history
  • Loading branch information
johnman committed Feb 19, 2024
2 parents 1231b4f + a39c267 commit 4492879
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions how-to/hints-and-tips/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ This section is where we will add small hints and tips that isn't specific to an
| [Preload Scripts](./docs/preload-scripts.md) | This document covers how you can configure preload scripts for your platform with some hints and tips. |
| [Protocol Links](./docs/protocol-support.md) | This document covers how you can configure protocol support for your OpenFin platform e.g. mailto:, msteams: etc. |
| [App Assets & Launch External Process](./docs/appassets-and-launch-external-process.md) | This document covers app assets, launch external process, how they work together, when would you use it and a deep dive into each feature. |
| [Platform Override - launchIntoPlatform](./docs/launch-info-platform.md) | Override launchIntoPlatform to control how content is loaded into your platform. |
69 changes: 69 additions & 0 deletions how-to/hints-and-tips/docs/launch-into-platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
> **_:information_source: OpenFin Workspace:_** [OpenFin Workspace](https://www.openfin.co/workspace/) is a commercial product and this repo is for evaluation purposes (See [LICENSE.MD](../../../LICENSE.MD)). Use of the OpenFin Container and OpenFin Workspace components is only granted pursuant to a license from OpenFin. Please [**contact us**](https://www.openfin.co/workspace/poc/) if you would like to request a developer evaluation key or to discuss a production license.
[<- Back to Table Of Contents](../README.md)

# [Launch Into Platform](https://developers.openfin.co/of-docs/docs/platform-getting-started#deep-linking-fin--fins-link)

OpenFin Platforms allow additional snapshots and layouts to be loaded into a platform through a deep link. This might be useful if you want to dynamically load content through a url, however, our recommendation would be that a platform developer should be more explicit about what gets loaded into their platform and how.

OpenFin lets you [customize the behavior of a platform](https://developers.openfin.co/of-docs/docs/platform-customization#example-overriding-default-getsnapshot-behavior) through overrides and you can do the same here.

## Override launchIntoPlatform - Platform API

```js
const overrideCallback = (Provider) => {
// Extend default behavior
class MyOverride extends Provider {
/**
* Supports launching a manifest into a platform.
* @param payload The manifest to load into the platform
* @returns nothing.
*/
async launchIntoPlatform(payload: OpenFin.LaunchIntoPlatformPayload): Promise<void> {
console.log(
"launchIntoPlatform called. Inspect the payload to determine if you should launch it by calling super.launchIntoPlatform or alternatively do not call super.launchIntoPlatform if you do not want to dynamically launch content in this way. If you want to implement your own logic against your own query param then look at implementing your own deep linking logic: https://developers.openfin.co/of-docs/docs/deep-linking .",
payload
);
}
}
// Return instance with methods to be consumed by Platform
return new MyOverride();
};
fin.Platform.init({ overrideCallback });
```

## Override launchIntoPlatform - Workspace Platform

```js
import * as WorkspacePlatform from '@openfin/workspace-platform';

/**
* Override methods in the platform.
* @param WorkspacePlatformProvider The workspace platform class to extend.
* @returns The overridden class.
*/
function overrideCallback(
WorkspacePlatformProvider: OpenFin.Constructor<WorkspacePlatformProvider>
): WorkspacePlatformProvider {
/**
* Create a class which overrides the platform provider.
*/
class Override extends WorkspacePlatformProvider {
async launchIntoPlatform(payload: OpenFin.LaunchIntoPlatformPayload): Promise<void> {
console.log(
"launchIntoPlatform called. Inspect the payload to determine if you should launch it by calling super.launchIntoPlatform or alternatively do not call super.launchIntoPlatform if you do not want to dynamically launch content in this way. If you want to implement your own logic against your own query param then look at implementing your own deep linking logic: https://developers.openfin.co/of-docs/docs/deep-linking .",
payload
);
}
}
return new Override();
}

// initialize Workspace Platform with Override
await WorkspacePlatform.init(
{
overrideCallback
});
```

Performing an override will let you disable this logic and as mentioned you can implement your own [deep linking logic](https://developers.openfin.co/of-docs/docs/deep-linking) to control all the parameters that are used when passing settings to your platform through a fins link.

0 comments on commit 4492879

Please sign in to comment.