bismarck-serializer-kotlinx

KotlinX bindings for Bismarck

License

License

Categories

Categories

Kotlin Languages Net
GroupId

GroupId

net.sarazan
ArtifactId

ArtifactId

bismarck-serializer-kotlinx
Last Version

Last Version

0.3.1
Release Date

Release Date

Type

Type

pom
Description

Description

bismarck-serializer-kotlinx
KotlinX bindings for Bismarck
Project URL

Project URL

https://github.com/asarazan/bismarck
Source Code Management

Source Code Management

https://github.com/asarazan/bismarck

Download bismarck-serializer-kotlinx

How to add to project

<!-- https://jarcasting.com/artifacts/net.sarazan/bismarck-serializer-kotlinx/ -->
<dependency>
    <groupId>net.sarazan</groupId>
    <artifactId>bismarck-serializer-kotlinx</artifactId>
    <version>0.3.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/net.sarazan/bismarck-serializer-kotlinx/
implementation 'net.sarazan:bismarck-serializer-kotlinx:0.3.1'
// https://jarcasting.com/artifacts/net.sarazan/bismarck-serializer-kotlinx/
implementation ("net.sarazan:bismarck-serializer-kotlinx:0.3.1")
'net.sarazan:bismarck-serializer-kotlinx:pom:0.3.1'
<dependency org="net.sarazan" name="bismarck-serializer-kotlinx" rev="0.3.1">
  <artifact name="bismarck-serializer-kotlinx" type="pom" />
</dependency>
@Grapes(
@Grab(group='net.sarazan', module='bismarck-serializer-kotlinx', version='0.3.1')
)
libraryDependencies += "net.sarazan" % "bismarck-serializer-kotlinx" % "0.3.1"
[net.sarazan/bismarck-serializer-kotlinx "0.3.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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()) // requires bismarck-serializer-kotlinx
    }
    freshness { 
        path = "users-freshness" // freshness state will survive shutdowns if you specify a path
        millis = 15 * 60 * 1000 // data is considered fresh for 15 minutes
    }
    fetcher {
        myApi.fetchAndProcessHundredsOfRecords()
    }
}

// Kick off a fetch with either check() or invalidate()
cache.check()

// Bismarck is coroutine-driven, 
// so async and observations should be scoped.
someScope.launch {

    // This will be called whenever the data is updated, as long as the scope continues.
    cache.eachValue {
        println("Received value ${it.bar}")
    }
    
    // It's helpful to know what your cache is doing. Observe state to find out!
    cache.eachState {
        spinner.isVisible = it == Bismarck.State.Fetching
    }
    
    // Same for error states!
    cache.eachError {
        warningIcon.isVisible = it != null
    }
}

// You can also grab all of these values directly
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.0.6
        }
    }
}

Versions

Version
0.3.1
0.3.0
0.1.0