TogetherSession.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/ui/screens/together/TogetherSession.kt
1package eu.friedcutlet.yokan.ui.screens.together23import kotlinx.coroutines.flow.MutableStateFlow4import kotlinx.coroutines.flow.StateFlow5import kotlinx.coroutines.flow.asStateFlow6import kotlinx.coroutines.flow.getAndUpdate7import kotlinx.coroutines.flow.update89/** Room code handed in by a deep link; the Together screen's view model joins it. */10object TogetherSession {11 private val _pendingCode = MutableStateFlow<String?>(null)1213 /** Room code handed in by a deep link, consumed by the Together screen. */14 val pendingCode: StateFlow<String?> = _pendingCode.asStateFlow()1516 fun offerCode(code: String) {17 _pendingCode.update { code }18 }1920 /** Returns the deep-linked room code once, clearing it. */21 fun takePendingCode(): String? = _pendingCode.getAndUpdate { null }22}23