-
Notifications
You must be signed in to change notification settings - Fork 939
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
Tab swiping: Feature flag cache #5323
Tab swiping: Feature flag cache #5323
Conversation
class IsSwipingTabsFeatureEnabled @Inject constructor( | ||
swipingTabsFeature: SwipingTabsFeature, | ||
) { | ||
private val isEnabled: Boolean = swipingTabsFeature.self().isEnabled() |
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.
are you sure this doens't call IO right when the class is instantiated? If it does (I think it does) we should change it.
Also, I would question why do you need this class anyway, you can more easily do the same (without the overhead of a whole new class) by using lazy
in the caller (RealTabManager)
nit: also about the invoke()
pattern, we don't use it very often and I think we should not use it. it's in general more difficult to get around when working with the IDE
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.
+1
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.
are you sure this doens't call IO right when the class is instantiated? If it does (I think it does) we should change it.
You mean when the SwipingTabsFeature
is being initialized for the first time? I don’t think so, at least from what I saw when stepping through the code. But I couldn’t peek inside the generated store so I may be wrong. We can initialize the variable lazily, though, to be safe.
Also, I would question why do you need this class anyway, you can more easily do the same (without the overhead of a whole new class) by using lazy in the caller (RealTabManager)
I’m checking for the flag in multiple places (not here but in a subsequent PR), so I need to store the value somewhere for consistency.
Task/Issue URL: https://app.asana.com/0/1207418217763355/1208852760335259/f
Description
This PR just caches the feature flag value.
I’ve set the scope of the
IsSwipingTabsFeatureEnabled
toAppScope
because it’s used inside theTabManager
, which is used across 2 different activities (BrowserActivity
andTabSwitcherActivity
).Steps to test this PR
Testing optional.