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:
- Apps: Constants representing various Growave applications that can be enabled in a custom storefront.
- 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
| Constant | Description |
|---|---|
INSTAGRAM | Represents the Instagram integration app. |
SOCIAL_LOGIN | Represents the Social Login app. |
QUESTIONS | Represents the Questions and Answers app. |
REVIEWS | Represents the Reviews app. |
REWARDS | Represents the Rewards and Loyalty app. |
TIKTOK | Represents the TikTok integration app. |
WISHLISTS | Represents 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
| Constant | Description |
|---|---|
AUTHENTICATION | Represents the Authentication module. |
REVIEWS | Represents the Reviews module. |
REWARDS | Represents the Rewards module. |
WISHLISTS | Represents 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.