How can I fix/detect Circular Dependencies
What protocol or workflow do you use to avoid Circular Dependencies or, if you already had them, what alternatives do you use? because in my case it's hard to create a large codebase that does not require circular dependencies

2 Replies
so in my case I have a GameplayService that mostly just saves "Gameplay" instances in a Map that run all of the control for the Player's Character while it's playing, so GameplayService requires Gameplay
but Gameplay also Requires GameplayService because when the Gameplay instance is destroyed I wanna delete it from the Map list from the gameplay, yes I could just make all the Code that could potentially destroy the Gameplay Class to GameplayService, but then I see this as a limitation because roblox normal module requiring can be circular
am I being dumb? is this a bad way of doing it?
and also is there any tool for detecting them so they dont just error on runtime?, I tried using Madge but I wasnt able to make it work, is it not supported on Roblox-ts? or I just dont know how to use it?
Your Gameplay instance shouldn't be responsible for deleting itself from GameplayService
make GameplayService listen for when the instance should be removed, then remove it from there
very generally speaking, if you have a circular dependency, there's a good chance a signal would get rid of it