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 PMBrendan Weinstein
12/28/2019, 8:42 PMJ茅r么me Gully
12/28/2019, 10:04 PMJ茅r么me Gully
12/28/2019, 10:06 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