Roots, bloody roots ...
Rx based data flow.
More or less it is
(1) Api >> (2) Cache >> (3) Consume >> (4) Something else
with every step optional and interchangeable.
Access all jitpack builds here.
All releases are available here.
Check out the repo and have fun.
- Java 17
- Android SDK
- Gradle
Build tool is gradle
Run ./gradlew assemble
Run ./gradlew test
Run ./gradlew lint
Run ./gradlew testDebugUnitTestCoverage
or ./gradlew testReleaseUnitTestCoverage
or ./scripts/tests
You can find the outputs here:
- for the lint
./roots/build/reports/lint-results-developmentDebug.html
- for the unit test coverage
./roots/build/reports/jacoco/testDebugUnitTestCoverage/html/index.html
or./roots/build/reports/jacoco/testReleaseUnitTestCoverage/html/index.html
- for the unit test summary
./roots/build/reports/tests/testDebugUnitTestCoverage/index.html
or./roots/build/reports/tests/testReleaseUnitTestCoverage/index.html
If you find this project interesting check out the ongoing issues and add your ides.
Get or Cache locally
@JsonIgnoreProperties(ignoreUnknown = true)
private class ApiResponse(
@JsonProperty("status") val status: String,
@JsonProperty("response") val response: String
)
val flow = TimedGet(
"https://663a13b71ae792804bedf83c.mockapi.io/api/v1/response/1",
ApiResponse::class.java,
TimeUnit.MINUTES.toMillis(1)
).flow
flow
.subscribe({ data ->
Timber.d("... ${data.status} ${data.response}")
}) { throwable ->
Timber.e("... $throwable")
}
This will:
- get from url and cache it locally
- keep it for 1 minute
- within 1 minute if requested again get it locally
- after 1 minute re-get it again (and cache it again)
Project link: https://mockapi.io/projects/663a13b71ae792804bedf83d