diff --git a/build.gradle.kts b/build.gradle.kts index 656a9a27..44cacd6f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,6 @@ +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.MavenPublishBasePlugin +import com.vanniktech.maven.publish.SonatypeHost import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent import org.jetbrains.dokka.gradle.DokkaTask @@ -9,7 +12,7 @@ plugins { kotlin("multiplatform") version "1.6.21" id("com.diffplug.spotless") version "6.6.1" id("maven-publish") - id("com.vanniktech.maven.publish") version "0.19.0" + id("com.vanniktech.maven.publish") version "0.20.0" id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.10.0" id("org.jetbrains.dokka") version "1.6.21" id("org.jetbrains.kotlinx.kover") version "0.5.1" @@ -188,9 +191,10 @@ spotless { } allprojects { - plugins.withId("com.vanniktech.maven.publish") { - mavenPublish { - sonatypeHost = com.vanniktech.maven.publish.SonatypeHost.S01 + plugins.withType { + extensions.configure { + publishToMavenCentral(SonatypeHost.S01) + signAllPublications() } } } diff --git a/src/commonMain/kotlin/com/hoc081098/flowext/defer.kt b/src/commonMain/kotlin/com/hoc081098/flowext/defer.kt index d5fb5ff9..9e460f21 100644 --- a/src/commonMain/kotlin/com/hoc081098/flowext/defer.kt +++ b/src/commonMain/kotlin/com/hoc081098/flowext/defer.kt @@ -34,5 +34,20 @@ import kotlinx.coroutines.flow.flow * * In some circumstances, waiting until the last minute (that is, until collection time) * to generate the [Flow] can ensure that collectors receive the freshest data. + * + * Example of usage: + * + * ``` + * suspend fun remoteCall1(): R1 = ... + * suspend fun remoteCall2(r1: R1): R2 = ... + * + * fun example1(): Flow = defer { + * val r1 = remoteCall1() + * val r2 = remoteCall2(r1) + * flowOf(r2) + * } + * + * fun example2(): Flow = defer { flowOf(remoteCall1()) } + * ``` */ public fun defer(flowFactory: suspend () -> Flow): Flow = flow { emitAll(flowFactory()) }