From b46d3e479531c8e6f5cd6f81bb37c279433147e7 Mon Sep 17 00:00:00 2001 From: Derek Ellis Date: Tue, 6 Feb 2024 13:50:57 -0500 Subject: [PATCH] Expose frameClock in StandardAppLifecycle (#1796) * Expose frameClock in StandardAppLifecycle * Update redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/StandardAppLifecycle.kt Co-authored-by: Jake Wharton --------- Co-authored-by: Jake Wharton --- .../cash/redwood/treehouse/StandardAppLifecycle.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/StandardAppLifecycle.kt b/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/StandardAppLifecycle.kt index e08118f6ce..33a6cd7d85 100644 --- a/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/StandardAppLifecycle.kt +++ b/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/StandardAppLifecycle.kt @@ -36,8 +36,12 @@ public class StandardAppLifecycle( private var started = false private lateinit var host: Host - private lateinit var broadcastFrameClock: BroadcastFrameClock - internal lateinit var frameClock: MonotonicFrameClock + private val broadcastFrameClock: BroadcastFrameClock = BroadcastFrameClock { + if (started) { + host.requestFrame() + } + } + public val frameClock: MonotonicFrameClock get() = broadcastFrameClock internal val mismatchHandler: ProtocolMismatchHandler = object : ProtocolMismatchHandler { override fun onUnknownEvent(widgetTag: WidgetTag, tag: EventTag) { @@ -63,10 +67,7 @@ public class StandardAppLifecycle( override fun start(host: Host) { check(!started) { "already started" } this.started = true - this.host = host - this.broadcastFrameClock = BroadcastFrameClock { host.requestFrame() } - this.frameClock = broadcastFrameClock prepareEnvironment(coroutineExceptionHandler) }