Nov 12, 2023
Sorry for the late response!
This way of injecting dependencies is not a new one because it has existed since v9 but with some limited use cases.
After a fix done in v14, this function became more powerful in the sense of opening some other places where it can be used, one of them being what you have mentioned here.
It is not the new, best practice way of injecting deps, but it has its use cases where it fits better than constructor injection.
FYI: I have used inject fn like this just for demo purposes.