Skip to content

Conversation

@andrewroycarter
Copy link

Description:

  • Adds Feature Flags to enable Trunk Based Development. Runtime changing via a debug menu is not present at the moment, but it's intended to be supported by this work if needed.
  • Adds initial unused listen mode feature flag
  • Adds tests around new Feature Flag functionality.

PaulKlauser and others added 2 commits October 1, 2024 23:14
Ladybug bundles JDK 21, which requires a Kotlin version bump, which in-turn requires a Room bump. No functional changes.
@andrewroycarter andrewroycarter added the enhancement New feature or request label Jan 27, 2025
@andrewroycarter andrewroycarter self-assigned this Jan 27, 2025
class RuntimeFlag(
private val sharedPreferences: IVocableSharedPreferences,
private val key: String,
private val defaultValue: Boolean
Copy link

@JonathanNye JonathanNye Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patterns for defining flags and accessing their state feels a little off here.

Imagine I'm writing code in some biz logic somewhere. If I want to check a runtime flag, it seems like I'd do something like this (I just borrowed it from your test):

FeatureFlags.RuntimeFlag(sharedPrefs, "test_flag", true).enabled

The onus is on me, random hunk of biz logic, to know the specific key for the feature and what its default should be. It seems like both of those ideas could be baked into some kind of sealed/enum-y type that defines individual flags and that could be passed to a thing that determines the state for you.

Something like...

enum class RuntimeFlag(key: String, default:Boolean) {
    LISTEN_MODE("listen_mode", false)
}

and then break the thing that resolves the flag out...

class RuntimeFlags(/* yadda, Shared Prefs probably */) {
    operator fun get(flag: RuntimeFlag): Boolean = /* yadda, read from disk */
}

and in situ... (I got cute with the indexing syntax operator, that's optional)

val runtimeFlags = RuntimeFlags(/* yadda */)
val isMyFeatureEnabled = runtimeFlags[RuntimeFlag.LISTEN_MODE]

@mattyohe mattyohe requested a review from Copilot January 27, 2025 20:48
* Build-time flags that are controlled via build configuration.
*/
object BuildTimeFlag : Flag {
override val enabled: Boolean = BuildConfig.ENABLE_LISTEN_MODE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this scale when there's more than one build-time flag?

@mattyohe mattyohe marked this pull request as ready for review January 28, 2025 15:16
@mattyohe mattyohe requested review from Copilot and removed request for Copilot January 28, 2025 16:41
@andrewroycarter andrewroycarter force-pushed the chore/update-kotlin-room branch from 581d4d6 to e415ab8 Compare January 30, 2025 18:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants