Tutorial: interop.joinSessionContextGroup

interop.joinSessionContextGroup

Join the current entity to session context group sessionContextGroupId and return a sessionContextGroup instance. If the sessionContextGroup doesn't exist, one will get created. Session Context Groups do not persist between runs and aren't present on snapshots.

Example

Say we want to have a Session Context Group that holds UI theme information for all apps to consume -

My color-picker View:

    const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');

    const myColorPickerElement = document.getElementById('color-palette-picker');
    myColorPickerElement.addEventListener('change', event => {
        themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
    });

In other views:

    const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');

    const changeColorPalette = ({ selection }) => {/* ... */};

    // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
    themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');