Jérôme Gully
12/28/2019, 11:33 AMclass MyApp : Application() {
val database: AppDatabase by lazy { AppDatabase.getInstance(this) }
val dataRepository: DataRepository by lazy { DataRepository(database.documentDao) }
}
Brendan Weinstein
12/28/2019, 8:42 PMJérôme Gully
12/28/2019, 10:04 PMthis
, how can I pass application instance (for context) in the companion object ?Brendan Weinstein
12/28/2019, 10:10 PMclass App : Application {
companion object {
lateinit var appInstance: App
val dateabase: AppDatabase by lazy { AppDatabase.getInstance(appInstance) }
}
onCreate {
appInstance = this
}
}
Jérôme Gully
12/28/2019, 10:11 PM