Skip to content

Commit

Permalink
Renames components.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmuvi-stripe committed Dec 23, 2024
1 parent 6bba27b commit dae2c69
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.stripe.android.financialconnections.analytics.logError
import com.stripe.android.financialconnections.browser.BrowserManager
import com.stripe.android.financialconnections.di.APPLICATION_ID
import com.stripe.android.financialconnections.di.DaggerFinancialConnectionsSheetComponent
import com.stripe.android.financialconnections.di.SharedComponentHolder
import com.stripe.android.financialconnections.di.FinancialConnectionsSingletonSharedComponentHolder
import com.stripe.android.financialconnections.domain.FetchFinancialConnectionsSession
import com.stripe.android.financialconnections.domain.FetchFinancialConnectionsSessionForToken
import com.stripe.android.financialconnections.domain.GetOrFetchSync
Expand Down Expand Up @@ -548,7 +548,7 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor(
.builder()
.application(app)
.savedStateHandle(savedStateHandle)
.sharedComponent(SharedComponentHolder.getComponent(app))
.sharedComponent(FinancialConnectionsSingletonSharedComponentHolder.getComponent(app))
.initialState(state)
.configuration(state.initialArgs.configuration)
.build().viewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.inject.Singleton

@Singleton
@Component(
dependencies = [SharedComponent::class],
dependencies = [FinancialConnectionsSingletonSharedComponent::class],
modules = [
FinancialConnectionsSheetModule::class,
FinancialConnectionsSheetSharedModule::class,
Expand All @@ -38,7 +38,7 @@ internal interface FinancialConnectionsSheetComponent {
@BindsInstance
fun configuration(configuration: FinancialConnectionsSheet.Configuration): Builder

fun sharedComponent(component: SharedComponent): Builder
fun sharedComponent(component: FinancialConnectionsSingletonSharedComponent): Builder

fun build(): FinancialConnectionsSheetComponent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import javax.inject.Singleton

@Singleton
@Component(
dependencies = [SharedComponent::class],
dependencies = [FinancialConnectionsSingletonSharedComponent::class],
modules = [
FinancialConnectionsSheetNativeModule::class,
FinancialConnectionsSheetSharedModule::class,
Expand Down Expand Up @@ -92,7 +92,7 @@ internal interface FinancialConnectionsSheetNativeComponent {
@BindsInstance
fun configuration(configuration: FinancialConnectionsSheet.Configuration): Builder

fun sharedComponent(component: SharedComponent): Builder
fun sharedComponent(component: FinancialConnectionsSingletonSharedComponent): Builder

fun build(): FinancialConnectionsSheetNativeComponent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ import dagger.Module
import dagger.Provides

/**
* A singleton holder for the [SharedComponent], ensuring it is initialized only once and
* A singleton holder for the [FinancialConnectionsSingletonSharedComponent], ensuring it is initialized only once and
* shared across activities.
*/
internal object SharedComponentHolder {
internal object FinancialConnectionsSingletonSharedComponentHolder {

@Volatile
private var sharedComponent: SharedComponent? = null
private var component: FinancialConnectionsSingletonSharedComponent? = null

fun getComponent(application: Application): SharedComponent {
return sharedComponent ?: synchronized(this) {
sharedComponent ?: buildComponent(application).also { sharedComponent = it }
fun getComponent(application: Application): FinancialConnectionsSingletonSharedComponent {
return component ?: synchronized(this) {
component ?: buildComponent(application).also { component = it }
}
}

private fun buildComponent(application: Application): SharedComponent {
private fun buildComponent(application: Application): FinancialConnectionsSingletonSharedComponent {
return DaggerSharedComponent.builder()
.application(application)
.build()
}
}

@Component(modules = [SharedModule::class])
internal interface SharedComponent {
@Component(modules = [FinancialConnectionsSingletonSharedModule::class])
internal interface FinancialConnectionsSingletonSharedComponent {

fun providesIntegrityRequestManager(): IntegrityRequestManager

Expand All @@ -43,19 +43,19 @@ internal interface SharedComponent {
@BindsInstance
fun application(app: Application): Builder

fun build(): SharedComponent
fun build(): FinancialConnectionsSingletonSharedComponent
}
}

@Module()
internal class SharedModule {
internal class FinancialConnectionsSingletonSharedModule {

@Provides
fun providesIntegrityStandardRequestManager(
context: Application,
context: Application
): IntegrityRequestManager = IntegrityStandardRequestManager(
cloudProjectNumber = 527113280969, // stripe-financial-connections
logError = { message, error -> Logger.getInstance(BuildConfig.DEBUG) },
logError = { message, error -> Logger.getInstance(BuildConfig.DEBUG).error(message, error) },
factory = RealStandardIntegrityManagerFactory(context)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.stripe.android.financialconnections.analytics.FinancialConnectionsEve
import com.stripe.android.financialconnections.di.APPLICATION_ID
import com.stripe.android.financialconnections.di.DaggerFinancialConnectionsSheetNativeComponent
import com.stripe.android.financialconnections.di.FinancialConnectionsSheetNativeComponent
import com.stripe.android.financialconnections.di.SharedComponentHolder
import com.stripe.android.financialconnections.di.FinancialConnectionsSingletonSharedComponentHolder
import com.stripe.android.financialconnections.domain.CompleteFinancialConnectionsSession
import com.stripe.android.financialconnections.domain.CreateInstantDebitsResult
import com.stripe.android.financialconnections.domain.NativeAuthFlowCoordinator
Expand Down Expand Up @@ -494,7 +494,7 @@ internal class FinancialConnectionsSheetNativeViewModel @Inject constructor(
.initialSyncResponse(args.initialSyncResponse.takeIf { state.firstInit })
.application(app)
.configuration(state.configuration)
.sharedComponent(SharedComponentHolder.getComponent(app))
.sharedComponent(FinancialConnectionsSingletonSharedComponentHolder.getComponent(app))
.savedStateHandle(savedStateHandle)
.initialState(state)
.build()
Expand Down

0 comments on commit dae2c69

Please sign in to comment.