Tutorial: PlatformProvider.getViewSnapshot

PlatformProvider.getViewSnapshot

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

Example

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

fin.Platform.init({ overrideCallback });