Dependency injection/IOC

I think an example of this would be Ecto. In cases like Ecto.Multi, the repo module is passed around so you can make sure you’re using the same repo during a transaction: Ecto.Multi — Ecto v3.14.0

A case where I did that was when doing something similar to the strategy pattern, I had many modules that were candidates to perform a given action, and when one of them was picked, I passed them around to the functions that would use it

1 Like