This project is named after the Kaluga, the world's biggest freshwater fish, which is found in the icy Amur river.
Kaluga's main goal is to provide access to common features used in cross-platform mobile app development, separated into modules such as architecture (MVVM), location, permissions, bluetooth etc.
To reach this goal it uses Kotlin, specifically Kotlin Multiplatform which allows running Kotlin code not just on JVM+Android, but also iOS/iPadOS, amongst others (inndeed some kaluga modules also work for Kotlin.js and/or JVM standalone).
Where appropriate coroutines and Flow are used in the API. This enables developers to use cold streams for a modern and efficient design.
While Kaluga modules can be used individually, together they form a comprehensive approach to cross-platform development with shared native code and native UIs, including SwiftUI and Compose.
Short examples
With Kaluga it is possible to create cross-platform functionality in a few lines of code, that would normally take many lines of code even on just one platform.
// will auto request permissions and try to enable bluetooth
BluetoothBuilder().create().devices().collect {
i("discovered device: $it") // log found device
}
Showing a spinner while doing some work:
suspendfundoWork(hudBuilder: HUD.Builder) {
hudBuilder.presentDuring { // shows spinner while code in this block is running// simulate doing work
delay(1000)
}
}
in this case, since HUD is a UI component the builder needs to be configured on the platform side:
val builder = HUD.Builder() // same for iOS and Android// ...
builder.subscribe(activity) // this needs be done in the Android source-set to bind the HUD to the lifecycle of the Activity// ...
builder.unsubscribe(activity) // when the Activity is stopped
However Kaluga's architecture module offers a cross-platform LifecycleViewModel class (which extends androidx.lifecycle.ViewModel on Android) that will automatically bind the builder to its lifecycle:
// this can just be in the commonMain sourceclassHudViewModel(privateval hudBuilder: HUD.Builder): BaseLifecycleViewModel(hudBuilder) {
suspendfundoWork() =
hudBuilder.presentDuring {
delay(1000)
}
}
More examples
Kaluga contains an example project that is used to test the developed modules.
Using Kaluga
For starting a new project based on Kaluga see the kaluga-starter repo, which shows how to do this step by step.
Kaluga is available on Maven Central. For example the Kaluga Alerts can be imported like this:
Of course not every possible functionality is provided by kaluga. However, this is often because other good multiplatform libraries that work nicely with kaluga already exist. These use similar patterns such as coroutines and Flow, and include the following:
We found that com.splendo.kaluga:bluetooth-androidlib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 0 open source maintainers collaborating on the project.
Package last updated on 11 Jun 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.