Bismarck (it syncs)
A new caching/syncing library for Kotlin Multiplatform
Under heavy construction. Better examples and instructions coming soon.
val cache = Bismarck.create<UserRecords> {
fileStorage {
path = "users.json"
serializer = JsonSerializer(UserRecords.serializer())
}
freshness {
path = "users-freshness"
millis = 15 * 60 * 1000
}
fetcher {
myApi.fetchAndProcessHundredsOfRecords()
}
}
cache.check()
someScope.launch {
cache.eachValue {
println("Received value ${it.bar}")
}
cache.eachState {
spinner.isVisible = it == Bismarck.State.Fetching
}
cache.eachError {
warningIcon.isVisible = it != null
}
}
val current = cache.value
Installation
repositories {
maven { url "https://dl.bintray.com/asarazan/maven" }
}
//...
sourceSets {
commonMain {
dependencies {
implementation "net.sarazan:bismarck:$bismarck_version" // currently 0.1.0
}
}
}