File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
features/dd-sdk-android-flags/src/main/kotlin/com/datadog/android/flags/internal Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -56,17 +56,17 @@ internal class FlagsStateManager(
5656 * Registers a listener to receive state change notifications.
5757 *
5858 * The listener will immediately receive the current state, then be notified
59- * of all future state changes.
59+ * of all future state changes. The current state is read atomically on the
60+ * same executor where all state updates occur, ensuring correct ordering.
6061 *
6162 * @param listener The listener to add.
6263 */
6364 fun addListener (listener : FlagsStateListener ) {
6465 subscription.addListener(listener)
6566
66- // Emit current state to new listener
67- val state = currentState
67+ // Emit current state to new listener - read inside executor for atomicity
6868 executorService.execute {
69- listener.onStateChanged(state )
69+ listener.onStateChanged(currentState )
7070 }
7171 }
7272
You can’t perform that action at this time.
0 commit comments