From 3ea9f438d12d9c027d5df21909590c3f9bc53822 Mon Sep 17 00:00:00 2001 From: Veyndan Stuart Date: Wed, 6 Dec 2023 12:00:56 +0100 Subject: [PATCH] Make `TreehouseApp`'s `ziplineFlow` a property --- .../kotlin/app/cash/redwood/treehouse/TreehouseApp.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseApp.kt b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseApp.kt index ca16e22a27..6001b223c1 100644 --- a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseApp.kt +++ b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseApp.kt @@ -47,7 +47,7 @@ public class TreehouseApp private constructor( * Continuously polls for updated code, and emits a new [LoadResult] instance when new code is * found. */ - private fun ziplineFlow(): Flow { + private val ziplineFlow: Flow = run { var loader = ZiplineLoader( dispatcher = dispatchers.zipline, manifestVerifier = factory.manifestVerifier, @@ -76,7 +76,7 @@ public class TreehouseApp private constructor( } } - return loader.load( + loader.load( applicationName = spec.name, manifestUrlFlow = spec.manifestUrl, serializersModule = spec.serializersModule, @@ -92,7 +92,7 @@ public class TreehouseApp private constructor( stateStore = factory.stateStore, ) { override fun codeUpdatesFlow(): Flow> { - return ziplineFlow().mapNotNull { loadResult -> + return ziplineFlow.mapNotNull { loadResult -> when (loadResult) { is LoadResult.Failure -> { null // EventListener already notified. @@ -167,7 +167,7 @@ public class TreehouseApp private constructor( private fun createCodeSession(zipline: Zipline): ZiplineCodeSession { val appService = spec.create(zipline) - // Extract the RealEventPublisher() created in ziplineFlow(). + // Extract the RealEventPublisher() created in ziplineFlow. val eventListener = zipline.eventListener as RealEventPublisher.ZiplineEventListener val eventPublisher = eventListener.eventPublisher