Clone repo:
git clone https://github.com/AlyStoned/df-iframe.git
Install yarn:
npm install --global yarn
yarn --version
Install project deps (in the project directory):
yarn install
Start local server:
yarn start
This is an example of using the exposed API of DF application (app.digifabster.com).
Exposed API - properties and functions of the DF application that you can use from another browser window.
We rely on the channel messaging from the browser API to expose our application's API. To simplify that process, we use comlink, this helps us build a neat way to communicate between windows. Comlink is the only peer dependency to use the exposed API since we use it inside the DF application. In this example we've also used @billjs/event-emitter to emit api ready event, but it's not necessary. Here is a possible implementation of the client part of the API, it's just a wrapper waiting for DF exposed API readiness signal.
The DF application is ready to listen for such calls:
transferModels, it takes a list of File objects as the first argument.
Usage example based on our implementation:
exposedApi.call(
'transferModels',
fileObjects.map(fileObject => fileObject.file),
);
interface ExposedAPI {
transferModels: (files: File[]) => void;
}