Understanding a flag freeze

Flag freeze

The flag freeze, unfreeze and freeze levels are only available on these client side SDKs

  • iOS (Swift, Objective-c, tvOS…​)

  • Android

  • JavaScript (Browser, React Native, Tizen…​)

The first time a flag is checked, the flag value will be frozen and kept for future evaluation. This will result in consistent behavior for the user. Any change in remote configuration (fetched configuration) or change in custom property values will not have an effect until the flag gets unfrozen.

The flag gets unfrozen in the following scenario:

  • Next App launch (or page loading in a browser) - when the app is launched, the flag value is checked by the app and the value gets calculated based on the last fetched configuration.

  • Next foreground event - (relevant only for mobile) when the app goes into the foreground the SDK calls unfreeze. This behavior can be controlled by defining different freeze levels.

  • Unfreeze - when the unfreeze function gets called either on flag level or on.

Flag freeze level

Flag freeze is available on client side SDKs by default. The default is set to untilForeground which means:

  • For mobile applications - the flag value is updated only on background and foreground changes.

  • For web frontend applications - the flag value is updated only on a new session.

You can disable freezing by default by implementing this code: Rox.setup(appKey, \{freeze: ‘none’});

Flag unfreeze

By default, in mobile SDKs, the value will remain frozen until the next foreground event. For Javascript SDK, the value will be frozen until the user closes the browser tab or window. Since a property value might change while the app is running, when a flag depends on a property, we might want to unfreeze the value of the flag. For example, we might have a flag that is false for anonymous users but true for register users. If a user logs in after a flag value was already checked and frozen to false, we will want to tell the SDK to unfreeze it so that it will evaluate as true.

The following are code examples of how to unfreeze the flag states. To unfreeze all the flags:

Swift Objective-C Android React Native JavaScript
Rox.unfreeze();
[Rox unfreeze];
Rox.unfreeze();
Rox.unfreeze();
Rox.unfreeze();

To unfreeze all flags under a specific namespace:

Swift Objective-C Android React Native JavaScript
ROXCore.unfreezeNamespace(namespace);
[ROXCore unfreezeNamespace:namespace];
Rox.unfreeze(namespace);
Rox.unfreeze(namespace);
Rox.unfreeze(namespace);

To unfreeze a specific flag:

Swift Objective-C Android React Native JavaScript
flag.unfreeze();
[flag unfreeze];
flag.unfreeze();
flag.unfreeze();
flag.unfreeze();

Flag freeze level

The following freeze levels for flags are available:

  • none - no freeze at all, the flag value will be evaluated every time its value gets called.

  • untilForeground (default behavior) - the flag is consistent from foreground to background.

  • untilLaunch - the flag is consistent until next launch time.

You can define flag level on an app level, defining the default flag level of the app using RoxOptions options.defaultFreezeLevel or when creating the flag by supplying the flag level to the constructor.

Swift Objective-C Android React Native JavaScript
let options = ROXOptions()
options.defaultFreezeLevel = .none
ROX.setup(withKey:appKey, options:options)

public let someFlag = RoxFlag(withDefault: false, freeze: .untilLaunch)!
ROXOptions *options = [[ROXOptions alloc] init];
options.defaultFreezeLevel = ROXFreeze_none;
[ROX setupWithKey:@"a8c00ba1f04cf4ecbb396a2" options:options];

self.someFlag = [RoxFlag[init] initWithDefaultValue: YES freeze: ROXFreeze_untilLaunch];
RoxOptions options = new RoxOptions.Builder().withFreeze(Freeze.None).build();
Rox.setup(this.getApplication(), options);

public RoxFlag someFlag = new RoxFlag(defaultValue, Freeze.UntilLaunch);
Rox.setup(appKey, {
  freeze: Rox.FreezeOptions.freezeOptionNone
});
someFlag: new Rox.Flag(false, { freeze: Rox.FreezeOptions.freezeOptionUntilLaunch });
Rox.setup(appKey, {
  freeze: 'none'
});
someFlag: new Rox.Flag(false, { freeze: 'untilLaunch' });