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
- Host: GitHub
- URL: https://github.com/satoshun/rxkotlincache
- Owner: satoshun
- License: apache-2.0
- Created: 2017-12-03T09:53:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T12:06:44.000Z (over 7 years ago)
- Last Synced: 2025-02-07T12:48:47.067Z (over 1 year ago)
- Topics: kotlin, rxjava2
- Homepage:
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](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
}
}
```