onceKmp
中文 README
onceKmp is a Kotlin Multiplatform library inspired by jonfinerty/Once, used to track one-off actions and rate-limited actions across app install, app version, and app session scopes.
Modules
onceKmp: publishable KMP library module.
onceKmpSample: sample wrapper module showing real usage.
Features
Coordinates
- Group:
io.github.mrjoechen
- Artifact:
oncekmp
- Kotlin package:
io.github.mrjoechen
- Android namespace:
io.github.mrjoechen
Install
Maven Central (recommended)
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.mrjoechen:oncekmp:<latest-version>")
}
}
}
Local multi-module dependency
settings.gradle.kts:
include(":onceKmp")
Consumer module:
dependencies {
implementation(project(":onceKmp"))
}
Initialize
Unified call for Android / iOS / Desktop:
Once.initialise()
Android explicit fallback:
Once.initialise(applicationContext)
Desktop/iOS custom app update timestamp:
Once.initialise(appUpdatedTimeMillis = 1_700_000_000_000L)
Desktop custom storage directory (optional):
Once.initialise(
storageDir = java.nio.file.Paths.get("/custom/path/for/oncekmp")
)
Usage Example
if (!Once.beenDone(Once.THIS_APP_VERSION, "show_whats_new")) {
Once.markDone("show_whats_new")
}
Storage Design (Important)
Once uses two persisted stores and one in-memory session list:
- Persisted map store name:
PersistedMapTagLastSeenMap
Platform Storage Details
Android
iOS
Desktop (JVM)
References