Marko Novakovic
02/06/2023, 9:07 PMinterface AccountStore {
val account: Flow<Account>
}
class AccountStoreImpl(platformAccountStore: PlatformAccountStore) : AccountStore {
override val account = platformAccountStore.account
}
expect class PlatformAccountStore {
val account: Flow<Account>
}
AccountStore
is abstraction and it’s used for testing and PlatformAccountStore
is, as name says, where I will implement Android and iOS specific behavioursPablichjenkov
02/06/2023, 9:11 PMMarko Novakovic
02/06/2023, 9:15 PMPablichjenkov
02/06/2023, 9:17 PMMarko Novakovic
02/06/2023, 9:17 PMrusshwolf
02/07/2023, 12:19 AMexpect class
is almost always redundant and just gives you another layer you have to change any time you adjust the interface. If you want to have a default in common without needing to inject anything, I usually do something like expect val defaultAccountStore
and then the actual
can be the platform implementation.Marko Novakovic
02/07/2023, 10:33 AMexpect
with interface
feels weird, thanks