Koin: Create singleton object which implements 2 interfaces

Created on 14 Mar 2020  路  1Comment  路  Source: InsertKoinIO/koin

single<ObserveLifeCycleState> { Communicator( domain = get(), repositoryMessanger = get() ) }

single<NewMessageListener> { Communicator( domain = get(), repositoryMessanger = get() ) }

As you can see I am instantiating the same 2 objects because it implements both interfaces. But this creates 2 different objects. How can I do it with only one initialization?

question

Most helpful comment

I believe single { Communicator(...) }.binds(ObserveLifeCycleState::class, NewMessageListener::class) should do it

>All comments

I believe single { Communicator(...) }.binds(ObserveLifeCycleState::class, NewMessageListener::class) should do it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LukasAnda picture LukasAnda  路  3Comments

iRYO400 picture iRYO400  路  3Comments

hkelidari picture hkelidari  路  3Comments

guymclean picture guymclean  路  3Comments

pchmielowski picture pchmielowski  路  3Comments