diff --git a/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExample.kt b/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExample.kt index f0d985e..188fe48 100644 --- a/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExample.kt +++ b/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExample.kt @@ -36,13 +36,13 @@ class SubscribeEventsExample( if (events.isNotEmpty()) { receivedEvents.addAll(events) } - yield() // Ensure coroutine checks for cancellation + yield() } } catch (e: CancellationException) { println("Data channel processing cancelled") } finally { println("Data channel processing finished") - dataChannel.cancel() // Ensure the channel is closed + dataChannel.cancel() } } diff --git a/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamExecutionData/SubscribeExecutionDataExample.kt b/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamExecutionData/SubscribeExecutionDataExample.kt index 1b940ec..121978f 100644 --- a/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamExecutionData/SubscribeExecutionDataExample.kt +++ b/kotlin-example/src/main/kotlin/org/onflow/examples/kotlin/streaming/streamExecutionData/SubscribeExecutionDataExample.kt @@ -9,7 +9,6 @@ import org.onflow.flow.sdk.crypto.PrivateKey class SubscribeExecutionDataExample( privateKey: PrivateKey, accessApiConnection: FlowAccessApi - ) { private val accessAPI = accessApiConnection private val connector = AccessAPIConnector(privateKey, accessAPI) @@ -67,4 +66,3 @@ class SubscribeExecutionDataExample( errorJob.join() } } - diff --git a/kotlin-example/src/test/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExampleTest.kt b/kotlin-example/src/test/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExampleTest.kt index 4e9eb79..f1d6dc7 100644 --- a/kotlin-example/src/test/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExampleTest.kt +++ b/kotlin-example/src/test/kotlin/org/onflow/examples/kotlin/streaming/streamEvents/SubscribeEventsExampleTest.kt @@ -33,7 +33,7 @@ internal class SubscribeEventsExampleTest { val receivedEvents = mutableListOf() try { val streamJob = launch { - withTimeoutOrNull(10_000L) { // Set timeout to ensure test completes in a reasonable time + withTimeoutOrNull(10_000L) { subscribeEventsExample.streamEvents(testScope, receivedEvents) } }