String-named

Report a typo

Imagine that we are developing a bank system for working with multi-currency accounts:

interface Wallet
class UsdWallet: Wallet
class BtcWallet: Wallet

There are two string-named Wallet components with both implementations:

val appModule = module {
    single<Wallet>(named("USD")) { UsdWallet() }
    single<Wallet>(named("BTC")) { BtcWallet() }
}

Write the code that will inject the Wallet component with the UsdWallet implementation in eager mode:

class Account: KoinComponent {
    private val wallet: Wallet = /* your code here */
}
Enter a short text
___

Create a free account to access the full topic