-
Notifications
You must be signed in to change notification settings - Fork 76
feat: State change notification for flags client #3025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
typotter
merged 28 commits into
develop
from
typo/FFL-1442-android-sdk-of-wrapper-implement-observe-method
Dec 1, 2025
+795
−30
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
af48d48
Flags Client State enum
typotter a0cc0cc
Add flags-openfeature module to local-ci
typotter 1d10ded
Client State observer and reg/unreg
typotter fe1b172
use DD core subscription, listeners, and implement new subscription m…
typotter 8035650
Flags State channel w/named state methods, listener paradigm and leve…
typotter 4d1923c
tests
typotter 856631b
api surface
typotter c9f9cbc
trim comments
typotter a44a582
detekt safe
typotter 2ffdd58
api
typotter d6d6538
refactor into FlagsStateManager
typotter 4478372
tidy listener api on FlagsClient
typotter a913a5c
hasFlags and tests
typotter 4a54161
state listeners
typotter 949a693
emit current state
typotter be53823
fix race
typotter d2b729d
separate executors, abstract state interaction out of FlagsClient
typotter 6d79a8b
lint imports
typotter f341b57
safe calls and sync on state
typotter 1cb6beb
lint
typotter 9332ebf
not using atomic reference for flags client state
typotter 81a95bd
comments and noop client is always ready
typotter acda00f
api import coroutines
typotter 5a288d8
add transitive deps
typotter 7fdd225
remove coroutines and Flow
typotter 740d7e7
no need to sync
typotter 952b5b8
Fix comments, tests, safe calls
typotter c8b1143
apply suggestion
typotter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ures/dd-sdk-android-flags/src/main/kotlin/com/datadog/android/flags/FlagsStateListener.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| * Copyright 2016-Present Datadog, Inc. | ||
| */ | ||
|
|
||
| package com.datadog.android.flags | ||
|
|
||
| import com.datadog.android.flags.model.FlagsClientState | ||
|
|
||
| /** | ||
| * Listener interface for receiving state change notifications from a [FlagsClient]. | ||
| * | ||
| * Implementations of this interface can be registered with a [FlagsClient] to receive | ||
| * callbacks whenever the client's state changes. | ||
| */ | ||
| interface FlagsStateListener { | ||
| /** | ||
| * Called when the state of the [FlagsClient] changes. | ||
| * | ||
| * @param newState The new state of the client. If the state is [FlagsClientState.Error], | ||
| * the error details are contained within the state object itself. | ||
| */ | ||
| fun onStateChanged(newState: FlagsClientState) | ||
| } |
61 changes: 61 additions & 0 deletions
61
features/dd-sdk-android-flags/src/main/kotlin/com/datadog/android/flags/StateObservable.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| * Copyright 2016-Present Datadog, Inc. | ||
| */ | ||
|
|
||
| package com.datadog.android.flags | ||
|
|
||
| import com.datadog.android.flags.model.FlagsClientState | ||
|
|
||
| /** | ||
| * Observable interface for tracking [FlagsClient] state changes. | ||
| * | ||
| * This interface provides two ways to observe state: | ||
| * 1. **Synchronous getter**: [getCurrentState] for immediate state queries | ||
| * 2. **Callback pattern**: [addListener]/[removeListener] for reactive observers | ||
| * | ||
| * ## Usage Examples | ||
| * | ||
| * ```kotlin | ||
| * // Synchronous getter | ||
| * val current = client.state.getCurrentState() | ||
| * if (current is FlagsClientState.Ready) { | ||
| * // Proceed | ||
| * } | ||
| * | ||
| * // Callback pattern | ||
| * client.state.addListener(object : FlagsStateListener { | ||
| * override fun onStateChanged(newState: FlagsClientState) { | ||
| * // Handle state change | ||
| * } | ||
| * }) | ||
| * ``` | ||
| */ | ||
| interface StateObservable { | ||
| /** | ||
| * Returns the current state synchronously. | ||
| * | ||
| * This method is safe to call from any thread. | ||
| * | ||
| * @return The current [FlagsClientState]. | ||
| */ | ||
| fun getCurrentState(): FlagsClientState | ||
typotter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Registers a listener to receive state change notifications. | ||
| * | ||
| * The listener will immediately receive the current state upon registration, | ||
| * then be notified of all future state changes. | ||
| * | ||
| * @param listener The [FlagsStateListener] to register. | ||
| */ | ||
| fun addListener(listener: FlagsStateListener) | ||
typotter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Unregisters a previously registered state listener. | ||
| * | ||
| * @param listener The [FlagsStateListener] to unregister. | ||
| */ | ||
| fun removeListener(listener: FlagsStateListener) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.