8000 the test shows that ZLayer could ignore actual values and use cached "image" of dependency by alek-w · Pull Request #6153 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

the test shows that ZLayer could ignore actual values and use cached "image" of dependency #6153

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

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

alek-w
Copy link
Contributor
@alek-w alek-w commented Dec 11, 2021

the test shows that ZLayer could ignore actual values and use cached "image" of dependency

@adamgfraser
Copy link
Contributor

I think this is expected behavior. Layers are memorized so the A layer is only built once and made available wherever it is needed in the dependency graph. If you want to build it again you can use the fresh operator.

@guersam
Copy link
Contributor
guersam commented Dec 14, 2021

I'm actually relying on this behavior. For example:

val userRepositoryLayer: URLayer[Database, UserRepository] = ???
val archivedUserRepositoryLayer: URLayer[Database, ArchivedUserRepository] = ???

val mainDBLayer: URLayer[DBConfig, Database] = ???
val archiveDBLayer: URLayer[DBConfig, Database] = ???

case class Config(mainDB: DBConfig, archiveDB: DBConfig)
val configLayer: ULayer[Config] = ???

val archiveProcess: RIO[UserRepository & ArchivedUserRepository, Unit] = ???

archiveProcess.provideCustomLayer(
  (configLayer.project(_.mainDB) >>> mainDBLayer >>> userRepositoryLayer) ++
  (configLayer.project(_.archiveDB) >>> archiveDBLayer >>> archivedUserRepositoryLayer)
)

@alek-w alek-w force-pushed the zlayer_deps_test branch 2 times, most recently from 76e3ba7 to 9ec6b15 Compare December 14, 2021 10:47
@alek-w
Copy link
Contributor Author
alek-w commented Dec 14, 2021

@adamgfraser is this test needed in the main branch?

@adamgfraser adamgfraser merged commit e25b84d into zio:master Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0