An open API service indexing awesome lists of open source software.

https://github.com/satoshun/rxkotlincache

simple cache for RxJava and Kotlin
https://github.com/satoshun/rxkotlincache

kotlin rxjava2

Last synced: about 1 year ago
JSON representation

simple cache for RxJava and Kotlin

Awesome Lists containing this project

README

          

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.satoshun.RxKotlinCache/rxkotlincache/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.satoshun.RxKotlinCache/rxkotlincache)

# RxKotlinCache

It's a simple cache for [RxJava2](https://github.com/ReactiveX/RxJava) and Kotlin.

RxKotlinCache don't cache a Error, only cache success and complete events.

## How to install?

use Gradle

```groovy
implementation 'com.github.satoshun.RxKotlinCache:rxkotlincache:0.1.1'
```

## How to use it?

It can wrap a FunctionX(method reference) with cache(before result).

```kotlin
class UserDao {
fun getUser(userId: Int) : Single {
// body
}
}

class UserRepository(private val userDao: UserDao) {
private val getUserFromCache = rxCache(userDao::getUser)

fun getUser(userId: Int) : Single {
return getUserFromCache(userId) // get userDao::getUser if not exists a cache
}
}
```