In this document, you’ve learned how to write a Tic-Tac-Toe application using ZLayers. I hope you’ve been able to appreciate the great power that ZLayer gives for building modular and composable applications in a more accessible and understandable way. At the same time, we have written some tests and seen how easy it is to define mock environments as ZLayers that can be provided for tests to make them executable.
You have also learned how to use ZIO Magic to reduce lots of boilerplate when preparing the environment for your applications. Thanks to that, you won’t have to worry about horizontal and vertical composition of ZLayers anymore. And the best thing is that, when ZIO 2.0 is released, the functionality of the ZIO Magic library will be first-class and you won’t need to include it separately (in fact, we have seen that ZIO 2.0.0-M1 already includes most of the functionality of ZIO Magic).
I hope the concepts related to the ZLayer data type are more clear to you now (if they weren’t before), and that you will start using it in your own applications to make them extremely much more modular and composable!
Finally, take a look at this really great talk by Kit Langton at ZIO World 2021, where he discusses the ZIO Module Pattern and ZIO Magic.