Dynamic runtime configuration

How to support dynamic runtime configuration

Utilising dynamic runtime configuration

You can use the platform's dynamic configuration for application settings that are loaded at runtime. You can also subscribe to changes in these settings. These may include styling options, metadata or feature toggling. Within Studio, these settings are found in the Project > Setup > Experience tab and are specified in your App Spec.

In order to use this capability, you will need to load the Project and obtain data from its fields as follows:

async function displayProject() {
  try {
    const project = await getProject();
    const {
      id,
      fields: { my_field }
    } = project;

  } catch (e) {
    console.error('Something went wrong!', e);
  }
}

You can be notified of any update on the project by using this snippet:

// Called whe the project fields are updated
const unsubscribeOnProjectFieldsUpdated = onProjectFieldsUpdated(
    project, 
    () => { console.log(project) }
);

// Called when the project listings are updated
const unsubscribeOnProjectListingsUpdated = onProjectListingsUpdated(
    project, 
    () => { console.log(project) }
);

// Called when an event is published
const unsubscribeOnEventPublished = onEventPublished(
    project, 
    (event) => { console.log(event) }
);

Last updated