Skip to content

Instantly share code, notes, and snippets.

@motorro
Created November 29, 2019 06:52
Show Gist options
  • Save motorro/59bd0535757d00f33936a2758bb2b062 to your computer and use it in GitHub Desktop.
Save motorro/59bd0535757d00f33936a2758bb2b062 to your computer and use it in GitHub Desktop.
Delegating repository or not
/**
* Does:
* - fetches data from couple of endpoints
* - calculates result
* - ???
*/
class NoRepositoryFetchTask(
@Named("backend1") private val backend1: ConnectionAssets,
@Named("backend1") private val backend1Auth: Authentication,
@Named("backend2") private val backend2: ConnectionAssets,
@Named("backend2") private val backend2Auth: Authentication,
@Named("io") private val io: Scheduler,
@Named("computation") private val computation: Scheduler
): BaseCommand<ResultData, SomeParams>(backend1, backend1Auth), WithSomeLoggingLikeAnko {
// Implementation
}
/**
* Somewhere in dagger modules or as a singleton
*/
open class SchedulersRepo(
@Named("io") val io: Scheduler,
@Named("computation") val computation: Scheduler
)
/**
* Does:
* - fetches data from couple of endpoints
* - calculates result
* - ???
*/
class WithFetchTask(
@Named("backend1") private val backendRepo1: BackendRepo,
@Named("backend2") private val backendRepo2: BackendRepo,
private val schedulers: SchedulersRepo
): BaseCommand<ResultData, SomeParams>(backendRepo1), WithSomeLoggingLikeAnko {
// Implementation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment