LobbyViewModel

class LobbyViewModel(val appState: AppStateImpl, val scope: CoroutineScope, val pickGame: (Game) -> Unit, val globalError: ReversiException? = null, val setGlobalError: (Exception?, ErrorType?) -> Unit) : ViewModel<LobbyUiState>

View model for the lobby screen managing game list, polling, and user interactions. Handles loading available games, polling for updates, and game selection.

Constructors

Link copied to clipboard
constructor(appState: AppStateImpl, scope: CoroutineScope, pickGame: (Game) -> Unit, globalError: ReversiException? = null, setGlobalError: (Exception?, ErrorType?) -> Unit)

Properties

Link copied to clipboard
protected open override val _uiState: MutableState<LobbyUiState>

The mutable internal UI state.

Link copied to clipboard

Global application state for game and UI updates.

Link copied to clipboard
open override val globalError: ReversiException?

Optional error to display on initial load.

Link copied to clipboard
private var knownNames: List<String>
Link copied to clipboard
private val pickGame: (Game) -> Unit

Callback function when a game is picked.

Link copied to clipboard
private var pollingJob: Job?
Link copied to clipboard
private val scope: CoroutineScope

Coroutine scope for launching async lobby operations.

Link copied to clipboard
Link copied to clipboard
open override val setGlobalError: (Exception?, ErrorType?) -> Unit

Callback to set a global error.

Functions

Link copied to clipboard
Link copied to clipboard
fun joinGame(game: LobbyLoadedState, pieceType: PieceType)
Link copied to clipboard
Link copied to clipboard
private suspend fun loadGamesAndUpdateState()
Link copied to clipboard
private suspend fun pollLobbyUpdates()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
suspend fun tryLoadGame(gameName: String, desiredType: PieceType): Game?