```@Parcelize class RemoteDeclarationRepository : ...
# android
i
Copy code
@Parcelize
class RemoteDeclarationRepository : DeclarationRepositoryInterface {

    private val declareService: ProActiveDeclareApi
        get() = Api()

    override fun getDeclarations(periodId: Int, offset: Int, limit: Int): Single<DeclarationsResponse> {
        return declareService.getDeclarations(periodId, offset, limit)
    }

    override fun getDeclarationPeriod(id: Int): Single<DeclarationPeriod> {
        return declareService.getPeriod(id).map { it.data }
    }       //and so on 50 times almost
a
Sorry, what do you mean by `I have to write 50 times the same variable
declareService
inside these override functions`?
i
That inside this snippet I have almost 50 methods, and inside each of them I have to write
declareService.getthis()
in one function, then the same in the next
declareService.getThat()
I would like to know if in kotlin there is a "wrapper" as the keyword
with
so that I can write only
getThis()
or
getThat
a
hmmm, maybe delegation should work?
Copy code
class RemoteDeclarationRepository : DeclarationRepositoryInterface, ProActiveDeclareApi by Api() {

    override fun getDeclarations(periodId: Int, offset: Int, limit: Int): Single<DeclarationsResponse> {
        return getDeclarations(periodId, offset, limit)
    }

    override fun getDeclarationPeriod(id: Int): Single<DeclarationPeriod> {
        return getPeriod(id).map { it.data }
    }
(then
ProActiveDeclareApi
would be a public api of
RemoteDeclarationRepository
, so maybe you don’t want that :P)
i
COOL
thank you Arek!