diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bf649d806..1cabba1eea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ New: Changed: - The `TreehouseApp` type is now an abstract class. This should make it easier to write unit tests for code that integrates Treehouse. +- The `TreehouseApp.Spec.bindServices()` function is now suspending. Fixed: - Using a `data object` for a widget of modifier no longer causes schema parsing to crash. diff --git a/redwood-treehouse-host/api/android/redwood-treehouse-host.api b/redwood-treehouse-host/api/android/redwood-treehouse-host.api index ac8d4707d6..d42f20cbf8 100644 --- a/redwood-treehouse-host/api/android/redwood-treehouse-host.api +++ b/redwood-treehouse-host/api/android/redwood-treehouse-host.api @@ -100,7 +100,7 @@ public abstract interface class app/cash/redwood/treehouse/TreehouseApp$Factory public abstract class app/cash/redwood/treehouse/TreehouseApp$Spec { public fun ()V - public abstract fun bindServices (Lapp/cash/zipline/Zipline;)V + public abstract fun bindServices (Lapp/cash/zipline/Zipline;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun create (Lapp/cash/zipline/Zipline;)Lapp/cash/redwood/treehouse/AppService; public fun getFreshnessChecker ()Lapp/cash/zipline/loader/FreshnessChecker; public fun getLoadCodeFromNetworkOnly ()Z diff --git a/redwood-treehouse-host/api/jvm/redwood-treehouse-host.api b/redwood-treehouse-host/api/jvm/redwood-treehouse-host.api index b18d55ca88..3a146167db 100644 --- a/redwood-treehouse-host/api/jvm/redwood-treehouse-host.api +++ b/redwood-treehouse-host/api/jvm/redwood-treehouse-host.api @@ -100,7 +100,7 @@ public abstract interface class app/cash/redwood/treehouse/TreehouseApp$Factory public abstract class app/cash/redwood/treehouse/TreehouseApp$Spec { public fun ()V - public abstract fun bindServices (Lapp/cash/zipline/Zipline;)V + public abstract fun bindServices (Lapp/cash/zipline/Zipline;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun create (Lapp/cash/zipline/Zipline;)Lapp/cash/redwood/treehouse/AppService; public fun getFreshnessChecker ()Lapp/cash/zipline/loader/FreshnessChecker; public fun getLoadCodeFromNetworkOnly ()Z diff --git a/redwood-treehouse-host/api/redwood-treehouse-host.klib.api b/redwood-treehouse-host/api/redwood-treehouse-host.klib.api index 021e5cac3d..19ffec3a9f 100644 --- a/redwood-treehouse-host/api/redwood-treehouse-host.klib.api +++ b/redwood-treehouse-host/api/redwood-treehouse-host.klib.api @@ -98,8 +98,8 @@ abstract class <#A: app.cash.redwood.treehouse/AppService> app.cash.redwood.tree open val serializersModule // app.cash.redwood.treehouse/TreehouseApp.Spec.serializersModule|{}serializersModule[0] open fun (): kotlinx.serialization.modules/SerializersModule // app.cash.redwood.treehouse/TreehouseApp.Spec.serializersModule.|(){}[0] - abstract fun bindServices(app.cash.zipline/Zipline) // app.cash.redwood.treehouse/TreehouseApp.Spec.bindServices|bindServices(app.cash.zipline.Zipline){}[0] abstract fun create(app.cash.zipline/Zipline): #A1 // app.cash.redwood.treehouse/TreehouseApp.Spec.create|create(app.cash.zipline.Zipline){}[0] + abstract suspend fun bindServices(app.cash.zipline/Zipline) // app.cash.redwood.treehouse/TreehouseApp.Spec.bindServices|bindServices(app.cash.zipline.Zipline){}[0] } } diff --git a/redwood-treehouse-host/src/appsJvmTest/kotlin/app/cash/redwood/treehouse/TreehouseTester.kt b/redwood-treehouse-host/src/appsJvmTest/kotlin/app/cash/redwood/treehouse/TreehouseTester.kt index 0610f386d5..86c7ee939f 100644 --- a/redwood-treehouse-host/src/appsJvmTest/kotlin/app/cash/redwood/treehouse/TreehouseTester.kt +++ b/redwood-treehouse-host/src/appsJvmTest/kotlin/app/cash/redwood/treehouse/TreehouseTester.kt @@ -103,7 +103,7 @@ internal class TreehouseTester( override val loadCodeFromNetworkOnly: Boolean get() = true - override fun bindServices(zipline: Zipline) { + override suspend fun bindServices(zipline: Zipline) { zipline.bind("HostApi", hostApi) } 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 7976293643..f9f76000e6 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 @@ -148,7 +148,8 @@ public abstract class TreehouseApp : AutoCloseable { public open val loadCodeFromNetworkOnly: Boolean get() = false - public abstract fun bindServices(zipline: Zipline) + public abstract suspend fun bindServices(zipline: Zipline) + public abstract fun create(zipline: Zipline): A } } diff --git a/samples/emoji-search/launcher/src/commonMain/kotlin/com/example/redwood/emojisearch/launcher/EmojiSearchAppSpec.kt b/samples/emoji-search/launcher/src/commonMain/kotlin/com/example/redwood/emojisearch/launcher/EmojiSearchAppSpec.kt index 4f5dc344f4..aa72951958 100644 --- a/samples/emoji-search/launcher/src/commonMain/kotlin/com/example/redwood/emojisearch/launcher/EmojiSearchAppSpec.kt +++ b/samples/emoji-search/launcher/src/commonMain/kotlin/com/example/redwood/emojisearch/launcher/EmojiSearchAppSpec.kt @@ -35,7 +35,7 @@ class EmojiSearchAppSpec( override fun isFresh(manifest: ZiplineManifest, freshAtEpochMs: Long) = true } - override fun bindServices(zipline: Zipline) { + override suspend fun bindServices(zipline: Zipline) { zipline.bind("HostApi", hostApi) } diff --git a/test-app/launcher/src/commonMain/kotlin/com/example/redwood/testapp/launcher/TestAppSpec.kt b/test-app/launcher/src/commonMain/kotlin/com/example/redwood/testapp/launcher/TestAppSpec.kt index 52c36ebe21..9e98c664f4 100644 --- a/test-app/launcher/src/commonMain/kotlin/com/example/redwood/testapp/launcher/TestAppSpec.kt +++ b/test-app/launcher/src/commonMain/kotlin/com/example/redwood/testapp/launcher/TestAppSpec.kt @@ -33,7 +33,7 @@ class TestAppSpec( override fun isFresh(manifest: ZiplineManifest, freshAtEpochMs: Long) = true } - override fun bindServices(zipline: Zipline) { + override suspend fun bindServices(zipline: Zipline) { zipline.bind("HostApi", hostApi) }