From 7d71820e0eeb110b1d967f469e1d737a7f4baaa3 Mon Sep 17 00:00:00 2001 From: kkalisz Date: Thu, 19 Sep 2024 22:26:24 +0200 Subject: [PATCH] fix lifecycle not handled in js targets --- .../jsMain/kotlin/moe/tlaster/precompose/PreComposeWindow.kt | 5 +++++ .../kotlin/moe/tlaster/precompose/PreComposeApp.kt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/precompose/src/jsMain/kotlin/moe/tlaster/precompose/PreComposeWindow.kt b/precompose/src/jsMain/kotlin/moe/tlaster/precompose/PreComposeWindow.kt index 48c65170..839ad690 100644 --- a/precompose/src/jsMain/kotlin/moe/tlaster/precompose/PreComposeWindow.kt +++ b/precompose/src/jsMain/kotlin/moe/tlaster/precompose/PreComposeWindow.kt @@ -6,6 +6,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.unit.IntSize import androidx.compose.ui.window.CanvasBasedWindow +import moe.tlaster.precompose.lifecycle.Lifecycle import moe.tlaster.precompose.lifecycle.LifecycleOwner import moe.tlaster.precompose.lifecycle.LifecycleRegistry import moe.tlaster.precompose.lifecycle.LocalLifecycleOwner @@ -74,4 +75,8 @@ class PreComposeWindowHolder : LifecycleOwner, BackDispatcherOwner { override val backDispatcher by lazy { BackDispatcher() } + + init { + lifecycle.updateState(Lifecycle.State.Active) + } } diff --git a/precompose/src/wasmJsMain/kotlin/moe/tlaster/precompose/PreComposeApp.kt b/precompose/src/wasmJsMain/kotlin/moe/tlaster/precompose/PreComposeApp.kt index b49f4479..a4457c6d 100644 --- a/precompose/src/wasmJsMain/kotlin/moe/tlaster/precompose/PreComposeApp.kt +++ b/precompose/src/wasmJsMain/kotlin/moe/tlaster/precompose/PreComposeApp.kt @@ -3,6 +3,7 @@ package moe.tlaster.precompose import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember +import moe.tlaster.precompose.lifecycle.Lifecycle import moe.tlaster.precompose.lifecycle.LifecycleOwner import moe.tlaster.precompose.lifecycle.LifecycleRegistry import moe.tlaster.precompose.lifecycle.LocalLifecycleOwner @@ -47,4 +48,8 @@ class PreComposeWindowHolder : LifecycleOwner, BackDispatcherOwner { override val backDispatcher by lazy { BackDispatcher() } + + init { + lifecycle.updateState(Lifecycle.State.Active) + } }