Interface FlagValueChangeListener
-
public interface FlagValueChangeListener
An event listener that is notified when a feature flag's value has changed for a specific evaluation context.Use this in conjunction with
FlagTracker.addFlagValueChangeListener(String, com.launchdarkly.sdk.LDContext, FlagValueChangeListener)
if you want the client to re-evaluate a flag for a specific evaluation context whenever the flag's configuration has changed, and notify you only if the new value is different from the old value. The listener will not be notified if the flag's configuration is changed in some way that does not affect its value for that context.
In the above example, the value provided inString flagKey = "my-important-flag"; LDContext contextForFlagEvaluation = LDContext.create("context-key-for-global-flag-state"); FlagValueChangeListener listenForNewValue = event -> { if (event.getKey().equals(flagKey)) { doSomethingWithNewValue(event.getNewValue().booleanValue()); } }; client.getFlagTracker().addFlagValueChangeListener(flagKey, contextForFlagEvaluation, listenForNewValue);
event.getNewValue()
is the result of callingclient.jsonValueVariation(flagKey, contextForFlagEvaluation, LDValue.ofNull())
after the flag has changed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onFlagValueChange(FlagValueChangeEvent event)
The SDK calls this method when a feature flag's value has changed with regard to the specified evaluation context.
-
-
-
Method Detail
-
onFlagValueChange
void onFlagValueChange(FlagValueChangeEvent event)
The SDK calls this method when a feature flag's value has changed with regard to the specified evaluation context.- Parameters:
event
- the event parameters
-
-