Dependency injection and module scripts

Let’s talk about organizing code in a Remote Event world. In my model client Requestors talk to server Controllers which use server Repliers to talk to client Receivers while Managers are more like data processing classes that don’t handle events.

The code is becoming hard to extend, as my GameStateReciever, when it receives the EndGameEvent, wants to turn off the visor UI so you can see the game end screen. Exposing VisorUIManager functionality to both the WeaponReplicationManager, which updates the visors ammo and current weapon using its child managers, and the GameStateReciever is a challenge for me conceptually.

Im considering either A) instantiating all client managers/requestors/recievers in one file and injecting the same VisorUIManager into both the WeaponReplicationManager and the GameStateReciever, B) some sort of formalized dependency injector like AngularJS has, or C) continue to do this nesting strategy.

What would you do? Here’s my tree for reference.
image
image

General comments on my code structure are much appreciated, as well as arguments for A B or C. Thanks in advance yall!

4 Likes

Just want to mention that #development-support:requests-for-code-feedback is generally the intended category for posts like this. That’s unless your code doesn’t work, which then it’s fine here.

1 Like

Moving there, thanks!