Skip to content

Commit

Permalink
Merge pull request #123 from arrow-kt/update-example
Browse files Browse the repository at this point in the history
Update example
  • Loading branch information
nomisRev authored May 8, 2024
2 parents 2914f41 + 310c80a commit ab87955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ kotlin {
val commonMain by getting {
dependencies {
implementation(project.rootProject)
implementation("io.arrow-kt:arrow-fx-coroutines:1.2.0")
implementation(libs.arrow.fx)
}
}

Expand Down
22 changes: 10 additions & 12 deletions example/src/commonMain/kotlin/io/arrow/suspendapp/example/Main.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package io.arrow.suspendapp.example

import arrow.continuations.SuspendApp
import arrow.fx.coroutines.resource
import arrow.fx.coroutines.resourceScope
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.delay

fun main() = SuspendApp {
resource {
install({ println("Creating some resource") }) { _, exitCase ->
println("ExitCase: $exitCase")
println("Shutting down will take 10 seconds")
delay(10_000)
println("Shutdown finished")
}
}
.use {
println("Application running with acquired resources.")
awaitCancellation()
resourceScope {
install({ println("Creating some resource") }) { _, exitCase ->
println("ExitCase: $exitCase")
println("Shutting down will take 10 seconds")
delay(10_000)
println("Shutdown finished")
}
println("Application running with acquired resources.")
awaitCancellation()
}
}

0 comments on commit ab87955

Please sign in to comment.