Hi everyone I have been facing an issue in js sdk and reaching out for help *Issue*: On updating a f...
n

Neha Thakur

over 1 year ago
Hi everyone I have been facing an issue in js sdk and reaching out for help Issue: On updating a feature flag value, getting those values after couple of app session Details: I'm using the feature flag feature of GB in a react native application Currently I don't want to auto refresh the features in a single app session, so while initialising the sdk, I'm passing auto refresh as false and because of that no subscribedInstances are created. The issue is that when I fetch feature,
onNewFeatureData
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!