-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ref #273 Need help for Effect Type
's Injection
#281
Comments
djx314
changed the title
Ref #273 Need help for Effect Type Injection
Ref #273 Need help for Mar 15, 2023
Effect Type
's Injection
sbt command sbt>wire-web-scala/reStart and input the url in browser. http://127.0.0.1:8080/api/cats or http://127.0.0.1:8080/api/{StringParameter} |
Can you create a minimised example, which would show the problem? |
@adamw |
Run result sbt:macwire-issue281> run
[info] running macwire.test.app.MainApp
resourceA value:5
resourceB value:2
macwire-issue281 executed successful.
[success] Total time: 1 s, completed 2023-3-17 3:41:23 |
Provide a quick fix and expect a more reasonable approach. class AppInjection {
lazy val namedInstance: Named = Named("macwire-issue281")
private case class ServiceBImpl(test: PrintString) {
def build(resourceB: DBResource): ServiceB = ServiceB(resourceB = resourceB, test = test)
}
def serviceCResource[F[_]]: Resource[F, ServiceC] = wire[DBResourceA].resource.flatMap(dbA =>
wire[DBResourceB].resource.flatMap(dbB =>
wire[PrintStringResource].resource.map { printlnString =>
lazy val serviceA: ServiceA = ServiceA(resourceA = dbA) // Injection by name.
lazy val serviceBImpl: ServiceBImpl = wire[ServiceBImpl]
lazy val serviceB: ServiceB = serviceBImpl.build(resourceB = dbB) // Injection by name and injection by type.
wire[ServiceC]
}
)
)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@adamw Can't reopen #273 and create a new issue since reproduct the problem.
I use
macwire
to implement a web-app'sinjection
usingcats-effect
with a simple way.And it seems that it works in any effect type.
But some code not works well.
Code Link
Line 20
andLine 21
can not usemacwire
since "injection by name" is the same as "injection by varible name" in this injection style. Hoping for help to make these code more friendly.The text was updated successfully, but these errors were encountered: