Replies: 1 comment 3 replies
-
While it may sound scary at first, dependencies really are like "global" singletons, but just without all the traditional baggage associated with singletons (such as coupling and last of testability). After all, a dependency's whole purpose is to talk to the outside world, and there is only one outside world. This is why dependencies aren't designed with a specific feature in mind, but rather designed only as communicating with the outside world. The environments from the old-style reducers were designed with a feature in mind, but also they just held onto dependencies that were passed through each layer of the application. They didn't have any logic or behavior of their own. So, we think it's definitely OK for a child feature to hit |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm using the protocols-beta version and it's working great, but I have a usage question. When it comes to state, if there is some state that is used by two different features we would put it in their common ancestor, but what about the analogous situation for dependencies? Would it be considered a code smell to access the same dependency (say a data repo or audio player) from different sibling reducers?
I mean presumably we have written the dependencies so that they can handle being called from different places, but it feels a little bit like we turn them into global singletons, and the parent will still be informed that we, say, pressed the
play
button down in a child reducer, so perhaps it's ok to run theaudioPlayer.play
task from the child directly?Beta Was this translation helpful? Give feedback.
All reactions