-
Notifications
You must be signed in to change notification settings - Fork 1
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
ANDROID-14297 Get Tweaks as suspend functions and non null #39
Conversation
@@ -39,6 +41,12 @@ open class Tweaks { | |||
|
|||
open fun <T> getTweakValue(key: String): Flow<T?> = tweaksBusinessLogic.getValue(key) | |||
|
|||
open fun <T> getTweakValue(key: String, defaultValue: T): Flow<T> = getTweakValue<T>(key).map { it ?: defaultValue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it should return a Flow of nullable T
(T?
). defaultValue
should be nullable as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, after having thought more about it, if you want a null default value you would probably be using the existing method. So ignore my comment 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, the idea is to avoid having a nullable result. The nullable one is the current one.
flowOf(defaultValue) | ||
|
||
open suspend fun <T> getTweak(key: String): T? = | ||
null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something is missing here 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the no-op module. We use it to provide an implementation of Tweaks that don't do anything, so we provide it to the release
build, while the real one only goes to debug
: https://github.com/Telefonica/b2p-germany-android/blob/main/app/build.gradle#L250
You can check it correctly in the flavors
view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry, didn't know that. I will see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a better implementation for the no-op
scenario, where we try to find a default value provided in the app, instead returning the default one or null
🎟️ Jira ticket
ANDROID-14297
🥅 What's the goal?
🚧 How do we do it?
Provide new useful functions
📘 Documentation changes?
🧪 How can I test this?