https://kotlinlang.org logo
Title
u

ursus

02/05/2019, 4:35 AM
Is it worth it to provide "lesser scoped" interface of the same instance, if its be "hacked" via casting?
interface ReadFooRepository {
	fun getFoos() : List<Foo>
}

class FooRepository : ReadFooRepository {
	override fun getFoos() ...
	fun saveFoo(foo: Foo) ...
}
@provides @singleton fooRepository() : FooRepository = FooRepository()
@provides readFooRepository(fooRepository: FooRepository) : ReadFooRepository = fooRepository
class FooViewModel(private val readFooRepository : ReadFooRepository)
 ... only consume values
h

hudsonb

02/05/2019, 4:46 AM
Kotlin does it with List
u

ursus

02/06/2019, 1:10 AM
hmm true, but arent they doing it for perf reasons?