luke_c
02/23/2021, 3:20 PMobject ExampleObjectHolder {
lateinit var repository: Repository
fun initialize(client: Client) {
this.repository = Repository(bffClient)
this.analytics = analyticsClient
}
}
We have a top-level function that calls it, and then starts an Activity
fun startFlow(host: Activity) {
ExampleObjectHolder.initialize(ServiceLocator.instance().client)
host.startActivityForResult(Flow.packIntent(host), REQUEST_CODE)
}
Then inside our Activity we have a ViewModel which gets the dependency from that object
private val viewModel by viewModels<FlowViewModel> {
FlowViewModelFactory(repository = ExampleObjectHolder.repository)
}
This is the point where it’s crashing, but I can’t figure out why because it’s initialized immediately before starting the Activity and the ViewModel accessing it. It’s also only crashing for a very small amount of users.Adam Powell
02/23/2021, 3:32 PMluke_c
02/23/2021, 4:16 PM