Is it worth it to provide "lesser scoped" interfac...
# codereview
u
Is it worth it to provide "lesser scoped" interface of the same instance, if its be "hacked" via casting?
Copy code
interface ReadFooRepository {
	fun getFoos() : List<Foo>
}

class FooRepository : ReadFooRepository {
	override fun getFoos() ...
	fun saveFoo(foo: Foo) ...
}
Copy code
@provides @singleton fooRepository() : FooRepository = FooRepository()
@provides readFooRepository(fooRepository: FooRepository) : ReadFooRepository = fooRepository
Copy code
class FooViewModel(private val readFooRepository : ReadFooRepository)
 ... only consume values
h
Kotlin does it with List
u
hmm true, but arent they doing it for perf reasons?