Refactoring global atom to dynamically bound one

Another alternative is consider incorporating some env map in all your functions, I find this pattern pretty useful and extensible, if you add this env in most of the functions in the middle, this can be a map that contains anything you want. One example is ring request, or pedestal interceptors, there is map that flows on your system, making a part of the system allows you do to any kind of changes. The dynamic binding for example, is quite trick if you need to use two different ones at the same time, the code gets messy quickly, while having it as an explicit param is liberating. So, in general, global state is evil, avoid it as much as possible.

2 Likes