fresh-helicopter-69423
03/01/2024, 8:01 AMonNewFeatureData
is called and it sets the newly fetched features only when you have any subscribedInstances
. Since I don't have any subscribed instances, the values are not set in the same app session but only updates the cache.
function onNewFeatureData(
key: string,
cacheKey: string,
data: FeatureApiResponse
): void {
......
updatePersistentCache();
// Update features for all subscribed GrowthBook instances
const instances = subscribedInstances.get(key);
instances && instances.forEach((instance) => refreshInstance(instance, data));
}
Proposed solution: a straight forward solution would be to add a condition to check if auto refresh is enabled or not
if (instances) {
//Update features for all subscribed GrowthBook instances
instances.forEach((instance) => setFeaturesOnInstance(instance, data));
} else {
instance && data && setFeaturesOnInstance(instance, data);
}
I wanted the understand the implications of these changes and is there any other way to solve this issue
TIA!happy-autumn-40938
03/05/2024, 7:50 PMloadFeatures()
.
The proposed fix would not work for cases when multiple SDKs are implemented in the same environment. Not all instances
are keyed to the same api host and key.fresh-helicopter-69423
03/11/2024, 7:18 AMhappy-autumn-40938
03/11/2024, 9:28 PMconfigureCache()
and setting a maxAge
equal to (or less than!) your staleTTL
.
Multiple SDKs per app instance - there are a few use cases:
• You might have 2 different SDK keys associated with different projects that need to be loaded at the same time
• You might be running the SDK on a NodeJS server which needs to keep many independent user states per each incoming request/response