Tutorial: PlatformProvider.quit


Allows overriding a platform's default shutdown behavior. All calls to Platform.quit will pass through the override.


const overrideCallback = (PlatformProvider) => {
    class Override extends PlatformProvider {
        async quit(payload, callerIdentity) {
            // Perhaps in our platform, we wish to take a snapshot and save it somewhere before shutting down
            const snapshot = await this.getSnapshot();
            await saveSnapshot(snapshot);
            return super.quit(payload, callerIdentity);
    return new Override();

fin.Platform.init({ overrideCallback });

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