Posted on Leave a comment

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 Leave a comment

Loading data from few sources by rxjava

Observable<Data> memory = ...;  
Observable<Data> disk = ...;  
Observable<Data> network = ...;
// Retrieve the first source with data
Observable<Data> source = Observable  
  .concat(memory, disk, network)
  .first();

Save data to cache

Observable<Data> networkWithSave = network.doOnNext(data -> {  
  saveToDisk(data);
  cacheInMemory(data);
});
Observable<Data> diskWithCache = disk.doOnNext(data -> {  
  cacheInMemory(data);
});

Update data

Observable<Data> source = Observable  
  .concat(memory, diskWithCache, networkWithSave)
  .first(data -> data.isUpToDate());