Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.45 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.45 KB

ce-injection-samples

This project try to show a new injection way in Scala2 and Scala3.

It's a http4s web application. Test page is

http://127.0.0.1:8080/list

In Scala 2 we use ThoughtWorksInc/dsl-domains-cats to handle many Resources in cats-effect. And we use scala implicit syntax to implement some injection like macwire's wire[T]. At least we use zio.ZEnvironment to create a module and use cats.Id to fix a type issue only in Scala 2.

Link to the main file

Start and stop command is

sbt>run2
sbt>stop2

In Scala 3.1 we use typelevel/cats-effect-cps to replace dsl-domains-cats since dsl-domains-cats only support Scala 2. We also use zio.ZEnvironment to create a module. And the usage of given is more simple.

Link to the main file

Start and stop command is

sbt>run31
sbt>stop31

In Scala 3.2 we just use for comprehensions embbed by given. This shows the powerful syntax of scala. zio.ZEnvironment is still used for moduling.
Anyway you can use the sample above like Scala 3.1.

Link to the main file

Start and stop command is

sbt>run32
sbt>stop32