Hey, i’m working on a signal module, it’s small project to learn and probably use it in the future
I decided to make something like Roblox does, but there is problem, because i don’t know how to handle coroutines without causing memory leak, or making coroutine not stop when listener is destroyed
Signal module is OOP class that stores callbacks under the listener, and when you want you can fire listeners, and to run callback you create another OOP object which contain info, but to run callback itself you need to run coroutine, to don’t yield the entire script if callback have task.wait, this is where the problem comes, i can’t create any proper reference to task.spawn
Ohh, okay. I’ve been having issues with trying to wait inside or in the general proximity of coroutines myself. I’d say you definitely want some events/functions here (bindable or remote, I know the difference but am not sure what’s more appropriate for your situation: server-server or server-client / client-server?).
I’m not very well experienced, so someone might know better than me here. One thing I noticed though; is there a reason you’re using task.spawn and coroutines?
Assuming you mean that by “one of them” you mean events or functions: I’m pretty sure events go one way but functions yield for a response (more experienced programmers may correct me here, and everywhere else).
A little more general information would be that you might like to use coroutines where you need to do two things at the same time / be able to interrupt your code (pause and resume), because as far as I’m aware, that’s their main advantage?