Tutorial: PlatformProvider.getSnapshot

PlatformProvider.getSnapshot

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

Example

const overrideCallback = (PlatformProvider) => {
    // Extend default behavior
    class MyOverride extends PlatformProvider {
        async getSnapshot(payload, callerIdentity) {
            // Call super to access vanilla platform behavior
            const snapshot = await super.getSnapshot();
            // Perform any additional logic needed
            const modifiedSnapshot = { ...snapshot, answer: 42 }
            await saveSnapshotToServer(modifiedSnapshot);
            return modifiedSnapshot;
        }
    }
    // Return instance with methods to be consumed by Platform
    return new MyOverride();
};
fin.Platform.init({ overrideCallback });

async function saveSnapshotToServer(snapshot) {
    // Send a snapshot to the server, store it locally somewhere, etc.
}