Tutorial: PlatformProvider.replaceLayout


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


const overrideCallback = (PlatformProvider) => {
    class Override extends PlatformProvider {
        async replaceLayout(payload, callerIdentity) {
            // Perhaps in our platform, we wish to save an updated snapshot each time a layout is replaced
            await super.replaceLayout(payload, callerIdentity);
            const updatedSnapshot = await fin.Platform.getCurrentSync().getSnapshot();
            await saveSnapshot(updatedSnapshot);
    return new Override();

fin.Platform.init({ overrideCallback });

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