-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Layer overwrite possible bug #8693
Comments
The more idiomatic solution is to use fresh, I think val layer: ZLayer[String, Nothing, Printer] = ZLayer.fromFunction(PrinterLive(_)).fresh If I remember correctly, by default ZLayer instances are shared. And fresh |
For any given type, you can have at most one service that implements that type. So layer sharing is on by default. One workaround is to create a |
I'm not sure if this is expected behavior or I am missing something about how ZLayers work.
Below code prints:
I would expect it to print:
but somehow the 2nd layer overwrite the first ones, even though they are injected separately
The fix is to change
val
intodef
The text was updated successfully, but these errors were encountered: