Closed budarin closed 1 year ago
It is an implementation detail; the concept from the post forces no constraints on how to do it.
The example in the text uses Hooks as “poor man's DI” and, for consistency, uses it when exposing adapters, too.
in this case, doesn't the module itself act like a handmade DI? 😊
If, in testing, there are no preferences or constraints on mocking a module versus injecting a stub as a dependency, it might.
vs
Calling functions that return a new service object each time leads to an overhead during code execution and also generates a bunch of garbage for GC. This is practically nothing - for the client, but if such code is used in SSR, this is already a problem