java - Provide methods in Dagger 2 -


i have problem, don't know why variable don't inject , equals null. provide method this:

@provides @singleton fun providesource(context: context): databasesource = databasesource(context, models.default, db_name, db_version)  @provides @singleton fun providestoredb(databasesource: databasesource): kotlinreactiveentitystore<store> = kotlinreactiveentitystore(kotlinentitydatastore(databasesource.configuration))  @provides @singleton @notnull fun providestores() : database<store> = persistentdatabase(store::class) 

and class model store:

it heir class "persistable".

@entity data class store(val id: long = 0, val name: string = "", val description: string = "", val date: string = "") : displayableitem, persistable 

class works db

@singleton class persistentdatabase <t: any> (val type: kclass<t>) : database <t> {     @inject     internal lateinit var store: kotlinreactiveentitystore<t>      override fun addresult(item: t): completable = store.insert(item).tocompletable()      override fun addlistresult(item: list<t>): completable = store.insert(item).tocompletable()      override fun deleteresult(item: t): completable = store.delete(item)      override fun getallresults(): single<list<t>> = (store select type).get().observable().tolist()      override fun removeallresults(): completable = store.delete(type).get().single().tocompletable() } 

in repository layer use this:

@inject lateinit var database: database<detectedlanguagetext>  fun gethistory(): single<list<detectedlanguagetext>> {     return database.getallresults()             .map { it.sortedbydescending { it.date } }             .transitsuccesstoemitter(historyemitter) } 

but when in function getallresults variable

    @inject     internal lateinit var store: kotlinreactiveentitystore<t> 

doesn't inject , equals null. why doesn't work me?

i can't see inject kotlinreactiveentitystore in persistentdatabase. create instance in provides method, no injection done.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -