Tutorial: Layout.replace

Layout.replace

Replaces a Platform window's layout with a new layout. Any views that were in the old layout but not the new layout will be destroyed. Views will be assigned a randomly generated name to avoid collisions.

Example

let windowIdentity;
if (fin.me.isWindow) {
    windowIdentity = fin.me.identity;
} else if (fin.me.isView) {
    windowIdentity = (await fin.me.getCurrentWindow()).identity;
} else {
    throw new Error('Not running in a platform View or Window');
}

const layout = fin.Platform.Layout.wrapSync(windowIdentity);

const newLayout = {
    content: [
        {
            type: 'stack',
            content: [
                {
                    type: 'component',
                    componentName: 'view',
                    componentState: {
                        name: 'new_component_A1',
                        processAffinity: 'ps_1',
                        url: 'https://www.example.com'
                    }
                },
                {
                    type: 'component',
                    componentName: 'view',
                    componentState: {
                        name: 'new_component_A2',
                        url: 'https://cdn.openfin.co/embed-web/chart.html'
                    }
                }
            ]
        }
    ]
};

layout.replace(newLayout);