Tutorial: PlatformProvider.closeView

PlatformProvider.closeView

Allows overriding a platform's default view closing behavior. All calls to Platform.closeView will pass through the override.

Example

const overrideCallback = (PlatformProvider) => {
    class Override extends PlatformProvider {
        async closeView(payload, callerIdentity) {
            const { view } = payload;
            // Perhaps in our platform, we want to take a snapshot and save it somewhere before closing certain views.
            if (view.name === 'my-special-view') {
                const snapshot = await fin.Platform.getCurrentSync().getSnapshot();
                await saveSnapshot(snapshot);
            }
            return super.closeView(options, callerIdentity);
        }
    }
    return new Override();
}

fin.Platform.init({ overrideCallback });

async function saveSnapshot(snapshot) {
    // Save the snapshot in localstorage, send to a server, etc.
}