zip
Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { combine(this.bind(), other.bind()) }Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { Pair(this.bind(), other.bind()) }Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind()) }Combines two independent resource values with the provided map function, returning the resulting immutable Resource value. The finalizers run in order of left to right by using flatMap under the hood, but zip provides a nicer syntax for combining values that don't depend on each-other.
Useful to compose up to 9 independent resources, see example for more details on how to use in code.
import arrow.fx.coroutines.*
class UserProcessor {
fun start(): Unit = println("Creating UserProcessor")
fun shutdown(): Unit = println("Shutting down UserProcessor")
fun process(ds: DataSource): List<String> =
ds.users().map { "Processed $it" }
}
class DataSource {
fun connect(): Unit = println("Connecting dataSource")
fun users(): List<String> = listOf("User-1", "User-2", "User-3")
fun close(): Unit = println("Closed dataSource")
}
class Service(val db: DataSource, val userProcessor: UserProcessor) {
suspend fun processData(): List<String> = userProcessor.process(db)
}
val userProcessor = resource {
UserProcessor().also(UserProcessor::start)
} release UserProcessor::shutdown
val dataSource = resource {
DataSource().also { it.connect() }
} release DataSource::close
suspend fun main(): Unit {
userProcessor.zip(dataSource) { userProcessor, ds ->
Service(ds, userProcessor)
}.use { service -> service.processData() }
}See also
if you want to combine independent resources in parallel
to combine resources that rely on each-other.
Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind(), d.bind()) }Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind(), d.bind(), e.bind()) }Deprecated
This method will be removed in Arrow 2.x.x in favor of the DSL
Replace with
import arrow.fx.coroutines.resource
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL.
In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issuesDeprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind(), d.bind(), e.bind(), f.bind(), g.bind()) }Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind(), d.bind(), e.bind(), f.bind(), g.bind(), h.bind()) }Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind(), d.bind(), e.bind(), f.bind(), g.bind(), h.bind(), i.bind()) }Deprecated
zip is redundant and will be removed in Arrow 2.x.x in favor of the DSL. In case you think this method should stay, please provide feedback and your use-case on https://github.com/arrow-kt/arrow/issues
Replace with
import arrow.fx.coroutines.resource
resource { map(this.bind(), b.bind(), c.bind(), d.bind(), e.bind(), f.bind(), g.bind(), h.bind(), i.bind(), j.bind()) }