-
Notifications
You must be signed in to change notification settings - Fork 663
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
[FC] Adds ActivityRetainedScope and broader singleton component #9821
[FC] Adds ActivityRetainedScope and broader singleton component #9821
Conversation
Diffuse output:
APK
|
5c4c9af
to
cc8fb23
Compare
} | ||
|
||
@Module | ||
internal class FinancialConnectionsSingletonSharedModule |
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.
We'll be adding the integrity manager here later in this stack.
fa975d8
to
81df1b9
Compare
c2335d0
to
18a1ac0
Compare
|
||
@Module | ||
internal object FinancialConnectionsSheetConfigurationModule { | ||
|
||
@Provides | ||
@Named(PUBLISHABLE_KEY) | ||
@Singleton | ||
@ActivityRetainedScope |
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.
Note that, given the new component structure, there's no room for mistakenly scoping a dependency as @singleton on a non shared component. Dagger would fail at compile time if one of these (or other module) dependencies are scoped as @singleton.
internal interface FinancialConnectionsSingletonSharedComponent { | ||
|
||
@Component.Builder | ||
interface Builder { |
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.
Nit: This could use Component.Factory
.
18a1ac0
to
6405e3c
Compare
Merge activity
|
Summary
Today, we're using the
@Singleton
dagger scope wrongly, as dependencies are not shared across activities or match the app's lifecycle (see docs).This PR replaces current
Singleton
scope usages byActivityRetainedScope
, that clearly defines the real scope of existing dependencies.Additionally, this PR includes a way to share dependencies across activities (real
@Singleton
scope), by defining a thread-safe singleton pattern forSharedComponentHolder
to manage shared dependencies (e.g., Play Integrity API) across activities.Motivation
We're preparing the ground to share the Integrity component across activities.
The idea is to call
Integrity#prepare
on Activity A (FinancialConnectionsSheetActivity
) and reuse the same Integrity instance in Activity B (FinancialConnectionsNativeActivity
) when generating tokens.Took the opportunity to fix our current scope setup.
Testing