https://kotlinlang.org logo
#codereview
Title
# codereview
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?
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

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?