Skip to main content

Constants

Overview​

The Common module in the Growave SDK includes a set of constants that are essential for interacting with various Growave applications and modules. These constants help developers identify and work with specific apps and modules within the Growave ecosystem, ensuring that your custom storefront is correctly configured and responsive to different Growave services.

Constants categories​

The constants in the Common module are divided into two main categories:

  1. Apps: Constants representing various Growave applications that can be enabled in a custom storefront.
  2. Modules: Constants representing various SDK modules, primarily used for checking module readiness.

Apps constants​

The apps constants identify the Growave applications your storefront interacts with, particularly useful when initializing the SDK or managing enabled apps.

Available app constants​

ConstantDescription
INSTAGRAMRepresents the Instagram integration app.
SOCIAL_LOGINRepresents the Social Login app.
QUESTIONSRepresents the Questions and Answers app.
REVIEWSRepresents the Reviews app.
REWARDSRepresents the Rewards and Loyalty app.
TIKTOKRepresents the TikTok integration app.
WISHLISTSRepresents the Wishlists app.

Usage example​

These constants are typically used during the SDK initialization process to specify which Growave apps should be enabled:

window.gw.sdk.init({
enabledApps: [
window.gw.sdk.common.constants.apps.INSTAGRAM,
window.gw.sdk.common.constants.apps.REVIEWS,
window.gw.sdk.common.constants.apps.WISHLISTS,
],
// Additional options...
});

Modules constants​

The modules constants identify specific SDK modules. These are useful for checking module readiness before performing related operations.

Available module constants​

ConstantDescription
AUTHENTICATIONRepresents the Authentication module.
REVIEWSRepresents the Reviews module.
REWARDSRepresents the Rewards module.
WISHLISTSRepresents the Wishlists module.

Usage example​

These constants are used to subscribe to the runIfModuleReady event to ensure that a module is fully initialized before interacting with it:

function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.REVIEWS;

window.gw.sdk.runIfModuleReady(moduleName, () => {
console.log(`${moduleName} module is ready`);
// Proceed with module-specific logic
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}

Summary​

The constants in the Common module are essential for configuring and interacting with the Growave SDK. They enable easy identification and integration of Growave's apps and modules, helping you build a robust and flexible custom storefront.