macwire icon indicating copy to clipboard operation
macwire copied to clipboard

Add support for tupled results in autowire

Open mbore opened this issue 3 years ago • 0 comments

Currently, to create more than one instance in autowire we need to define a helper case class that wraps target instances (e.g. https://github.com/softwaremill/bootzooka/pull/766/files#diff-a9ca80cae7dddc8a64f16da196fc18bf18aff6cbaa4a996a872c0228d1eaddc5R21) We should be able to return tupled result instances instead. Test case:

case class A()
case class B()

object Test {
  val tuple = autowire[(A, B)]()
}

val tuple: (A, B) = {
  import cats.effect.unsafe.implicits.global
  Test.tuple.allocated.unsafeRunSync()._1
}

require(tuple._1 == A())
require(tuple._2 == B())

mbore avatar Jan 11 '22 06:01 mbore