https://github.com/sellmair/pacemaker
App for monitoring a whole groups heart rate, notifying the whole group if one exceeds his personal limit
https://github.com/sellmair/pacemaker
app bluetooth bluetooth-low-energy heart-rate kmp kotlin running
Last synced: about 1 year ago
JSON representation
App for monitoring a whole groups heart rate, notifying the whole group if one exceeds his personal limit
- Host: GitHub
- URL: https://github.com/sellmair/pacemaker
- Owner: sellmair
- Created: 2023-02-20T08:53:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-07T06:23:37.000Z (over 1 year ago)
- Last Synced: 2025-03-30T03:11:04.283Z (about 1 year ago)
- Topics: app, bluetooth, bluetooth-low-energy, heart-rate, kmp, kotlin, running
- Language: Kotlin
- Homepage:
- Size: 3.41 MB
- Stars: 121
- Watchers: 6
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Pacemaker (iOS & Android) [KMP]
[](https://github.com/sellmair/pacemaker/actions/workflows/build.yaml)
Run together! A running companion monitoring the heart rate of a group of people doing sports together.
## Supports
- External Bluetooth (LE) heart rate monitors (tested with Polar H10)
- iPhone <-> iPhone connections (No internet necessary, BLE)
- Android <-> Android connections (No internet necessary, BLE)
- iPhone <-> Android connections (No internet necessary, BLE)
## Planned
WatchOS support (via UWB chip and Internet)
## Screenshots
## Install
- Google Play: https://play.google.com/store/apps/details?id=io.sellmair.pacemaker
- Apple App Store: https://apps.apple.com/us/app/pacemaker-heart-rate-monitor/id6446760560
# Technical Details
## Kotlin Multiplatform
This application is built as a Test/Dogfooding project for Kotlin/Multiplatform, Compose and JetBrains Fleet.
## Architecture
### No! ViewModels!: This project uses 'State Actors' instead.
The State Actor pattern used in 'Pacemaker' can be defined by two high level concepts:
#### Events
Every component in the application can emit any kind of event, including intents.
Example: Some UI button that emits an event to the application
```kotlin
@Composable
fun MyButton() {
Button(
onClick = Launching { LoginIntent.emit() }
) {
// ...
}
}
```
#### State Producers
States can be produced and observed. Lets look at the producing site first:
Lets take the classic login example:
```kotlin
data class LoginState(val email: String, val password: String, val isLoggedIn: Boolean) : State {
companion object Key : State.Key {
val default get() = LoginState(email = "", password = "", isLoggedIn = false)
}
}
fun CoroutineScope.launchLoginStateActor() = launchState(LoginState) {
var state = LoginState.default
collectEventsAsync {
state = state.copy(email = it.email)
state.emit()
}
collectEventsAsync {
state = state.copy(password = it.password)
state.emit()
}
collectEventsAsync {
val isLoggedIn = attemptLogin(state.email, state.password)
state = state.copy(isLoggedIn = isLoggedIn)
state.emit()
}
}
```
Such states can then be used in the Application UI/Frontend easily
```kotlin
@Composable
fun MyLoginScreen() {
val loginState by LoginState.collectAsState()
MyLoginScreen(
email = loginState.email,
password = loginState.password
)
}
@Composable
fun MyLoginScreen(
email: String,
password: String
) {
Text(email)
Text(password)
Button(
onClick = Launching { LoginIntent.emit() }
) {
Text("Login")
}
}
```
### Libraries used
- kotlinx.coroutines
- kotlinx.datetime
- SQLDelight
- Multiplatform Settings
- Okio