Skip to content

Commit

Permalink
Add todo for resource factory method
Browse files Browse the repository at this point in the history
  • Loading branch information
mbore committed Oct 12, 2021
1 parent 0d2d0d0 commit 6b43819
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import com.softwaremill.macwire.catseffectsupport._

#include commonSimpleClasses
import cats.effect._

val factoryParams = scala.collection.mutable.ListBuffer[B]()

object Test {
def theA(b: B): Resource[IO, A] = { factoryParams.addOne(b); Resource.pure(A()) }
val theB: Resource[IO, B] = Resource.pure(B())
val theC: Resource[IO, C] = wireApp[C](theA _, theB)
}

val theC: C = {
import cats.effect.unsafe.implicits.global
Test.theC.allocated.unsafeRunSync()._1
}

require(theC.a != null)
require(theC.b != null)

require(factoryParams.length == 1)
require(factoryParams.head eq theC.b)

0 comments on commit 6b43819

Please sign in to comment.