Skip to content

Commit

Permalink
Make TreehouseApp's ziplineFlow a property
Browse files Browse the repository at this point in the history
  • Loading branch information
veyndan committed Dec 6, 2023
1 parent a914d68 commit 3ea9f43
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class TreehouseApp<A : AppService> private constructor(
* Continuously polls for updated code, and emits a new [LoadResult] instance when new code is
* found.
*/
private fun ziplineFlow(): Flow<LoadResult> {
private val ziplineFlow: Flow<LoadResult> = run {
var loader = ZiplineLoader(
dispatcher = dispatchers.zipline,
manifestVerifier = factory.manifestVerifier,
Expand Down Expand Up @@ -76,7 +76,7 @@ public class TreehouseApp<A : AppService> private constructor(
}
}

return loader.load(
loader.load(
applicationName = spec.name,
manifestUrlFlow = spec.manifestUrl,
serializersModule = spec.serializersModule,
Expand All @@ -92,7 +92,7 @@ public class TreehouseApp<A : AppService> private constructor(
stateStore = factory.stateStore,
) {
override fun codeUpdatesFlow(): Flow<CodeSession<A>> {
return ziplineFlow().mapNotNull { loadResult ->
return ziplineFlow.mapNotNull { loadResult ->
when (loadResult) {
is LoadResult.Failure -> {
null // EventListener already notified.
Expand Down Expand Up @@ -167,7 +167,7 @@ public class TreehouseApp<A : AppService> private constructor(
private fun createCodeSession(zipline: Zipline): ZiplineCodeSession<A> {
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

Expand Down

0 comments on commit 3ea9f43

Please sign in to comment.