diff --git a/sharedUI/src/commonMain/kotlin/com/livrets/App.kt b/sharedUI/src/commonMain/kotlin/com/livrets/App.kt index bcc8b16..39fadc7 100644 --- a/sharedUI/src/commonMain/kotlin/com/livrets/App.kt +++ b/sharedUI/src/commonMain/kotlin/com/livrets/App.kt @@ -41,7 +41,6 @@ fun App( is Screen.Game -> GameScreen( config = current.config, - scope = scope, onFinish = { result -> screen = Screen.Results(result) scope.launch { history.save(result) } diff --git a/sharedUI/src/commonMain/kotlin/com/livrets/ui/GameScreen.kt b/sharedUI/src/commonMain/kotlin/com/livrets/ui/GameScreen.kt index 25cf6d2..425ecb6 100644 --- a/sharedUI/src/commonMain/kotlin/com/livrets/ui/GameScreen.kt +++ b/sharedUI/src/commonMain/kotlin/com/livrets/ui/GameScreen.kt @@ -26,6 +26,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -37,15 +38,14 @@ import com.livrets.game.GameConfig import com.livrets.game.GameEngine import com.livrets.game.GameResult import com.livrets.game.GameState -import kotlinx.coroutines.CoroutineScope @Composable fun GameScreen( config: GameConfig, - scope: CoroutineScope, onFinish: (GameResult) -> Unit, onQuit: () -> Unit, ) { + val scope = rememberCoroutineScope() val engine = remember(config) { GameEngine(config, scope, onFinish = onFinish) } val state by engine.state.collectAsState()