dhruva
0.1.1indexedOne-shot and continuous location tracking with configurable timeouts and intervals, lifecycle-aware updates, typed error returns, battery-optimized defaults, and UI-friendly factory.
One-shot and continuous location tracking with configurable timeouts and intervals, lifecycle-aware updates, typed error returns, battery-optimized defaults, and UI-friendly factory.
ध्रुव, the polestar. The unmoving guide that helps you find where you are.
A small Kotlin Multiplatform location library for Android and iOS. One-shot and continuous tracking, with the right defaults baked in.
Location code looks the same in every Android codebase: import FusedLocationProviderClient,
write a LocationCallback, deal with foreground / background lifecycle, marshal to a
Flow. On iOS it's CLLocationManager, a CLLocationManagerDelegate, lifecycle
hooks. None of it is hard, but all of it is paperwork.
Dhruva is the paperwork:
LocationTracker interface with and .@Composable
fun WhereAmI() {
val tracker = rememberLocationTracker()
var label by remember { mutableStateOf("Tap to find me") }
val scope = rememberCoroutineScope()
Button(onClick = {
scope.launch {
label = runCatching { tracker.getCurrentLocation() }
.map { "${it.latitude}, ${it.longitude}" }
.getOrElse { e -> "Couldn't locate: " }
}
}) {
Text(label)
}
}
Continuous tracking:
LaunchedEffect(Unit) {
tracker.startTracking(LocationConfig(updateIntervalMs = 5_000))
.collect { location ->
map.center(location)
}
}
FusedLocationProviderClient,
so the host app must include Google Play Services.CLLocationManager directly, no extra dependencies.dhruva-geocoding module.LocationManager directly, for FOSS distribution.See CONTRIBUTING.md. PRs welcome.
Dhruva is named for ध्रुव, the polestar in Indian astronomy, traditionally the fixed point that mariners used to find their way home.
getCurrentLocation()startTracking()FusedLocationProviderClient (battery-optimized, the
Google-blessed default).CLLocationManager, with a delegate that already does the
bridging dance.LocationErrors; nothing throws across the bridge.Flow<Location>LocationErrors.rememberLocationTracker() for Compose; plain interface
for non-Compose code.| Artifact | Purpose | Required? |
|---|
io.github.ksharma-xyz:dhruva-state | Location, LocationConfig, LocationPriority, LocationError. | yes |
io.github.ksharma-xyz:dhruva-data | LocationTracker interface and Android/iOS implementations. | yes |
io.github.ksharma-xyz:dhruva-di-koin | Optional Koin module factory. | optional |
Surfaced from shared tags and platforms — no rankings paid for.