Skip to content

Commit

Permalink
Expose frameClock in StandardAppLifecycle (#1796)
Browse files Browse the repository at this point in the history
* Expose frameClock in StandardAppLifecycle

* Update redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/StandardAppLifecycle.kt

Co-authored-by: Jake Wharton <[email protected]>

---------

Co-authored-by: Jake Wharton <[email protected]>
  • Loading branch information
dellisd and JakeWharton authored Feb 6, 2024
1 parent c1a7971 commit b46d3e4
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
Expand Down

0 comments on commit b46d3e4

Please sign in to comment.