Is this a suitable way to initiate some work at st...
# koin-contributors
y
Is this a suitable way to initiate some work at startup?
Copy code
single { CoroutineScope(Dispatchers.Default + SupervisorJob() ) }

    single<PeopleInSpaceRepositoryInterface>(createdAtStart = true) {
        PeopleInSpaceRepository()
            .also {
                get<CoroutineScope>().launch {
                    it.fetchAndStorePeople()
                }
            }
    }
r
I would generally recommend not having side effects when you're constructing your dependency graph, because in 6 months when you're trying to debug why a certain call is happening in a certain order it's going to be confusing.
👍 2
y
Yeah, I agree with this advice but fear it means duplicating some startup process.
p
Agree with Russell. Coming from Android, I’ve definitely found this pattern inconvenient, especially for ViewModel init blocks. They seem convenient but will definitely be painful if you have a
checkModules()
test
👍 1