Tutorial: PlatformProvider.closeWindow

PlatformProvider.closeWindow

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

This method calls a number of Platform Provider methods:
PlatformProvider.getViewsForWindowClose
PlatformProvider.checkViewsForPreventUnload
PlatformProvider.getUserDecisionForBeforeUnload
PlatformProvider.handleViewsAndWindowClose

Example

const overrideCallback = (PlatformProvider) => {
    class Override extends PlatformProvider {
        async closeWindow(payload, callerIdentity) {
            const { windowId: { uuid, name }, options: { skipBeforeUnload } } = payload;
            console.log(`${uuid}/${name} is closing and skipBeforeUnload is set to: ${skipBeforeUnload}`);
            return super.closeWindow(payload, callerIdentity);
        }
    }
    return new Override();
}

fin.Platform.init({ overrideCallback });