Posted on

Kotlin DSL

Domain-specific language

Kotlin dsl (pdf)

Kotlin DSL to write Gradle scripts on Android: Step by step walkthrough (pdf)

How do Kotlin DSL libraries work? [https://brunoaybar.com/how-do-kotlin-dsl-libraries-work]

Converting your Android Gradle scripts to Kotlin [https://proandroiddev.com/converting-your-android-gradle-scripts-to-kotlin-1172f1069880]

Migrating build logic from Groovy to Kotlin
[https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/]

The New Way of Writing Build Gradle with Kotlin DSL
[https://proandroiddev.com/the-new-way-of-writing-build-gradle-with-kotlin-dsl-script-8523710c9670]

Kotlin DSL —defining mandatory parameters
[https://blog.kotlin-academy.com/kotlin-dsl-know-your-limits-2deaef1bab66]

Posted on

Loading data from few sources by rxjava

[code language=”java”]
Observable<Data> memory = …;
Observable<Data> disk = …;
Observable<Data> network = …;
// Retrieve the first source with data
Observable<Data> source = Observable
.concat(memory, disk, network)
.first();
[/code]

Save data to cache

[code language=”java”]
Observable<Data> networkWithSave = network.doOnNext(data -> {
saveToDisk(data);
cacheInMemory(data);
});
Observable<Data> diskWithCache = disk.doOnNext(data -> {
cacheInMemory(data);
});
[/code]

Update data

[code language=”java”]
Observable<Data> source = Observable
.concat(memory, diskWithCache, networkWithSave)
.first(data -> data.isUpToDate());
[/code]