Quenty / NevermoreEngine

ModuleScript loader with reusable and easy unified server-client modules for faster game development on Roblox
https://quenty.github.io/NevermoreEngine/
MIT License
421 stars 124 forks source link

Implement Deferred/Adapted Signal using Lua #463

Open lucasmz-dev opened 6 months ago

lucasmz-dev commented 6 months ago

What package is this for? Signal

Describe your problem Currently, Signal by defaults uses GoodSignal which has some issues but is nice, but it also has the option of the older standard that uses BindableEvents. BindableEvents allow for Deferred (Adaptive) behavior which is important, GoodSignal doesn't. At the same time however, BindableEvents suck. They cause memory leaks which may not be detected by the user.

Describe the solution you'd like

We should abandon the BindableEvent approach. It is slower, leakier, just plain worse. We now have the power of Lua Signals, have had so for a long time. But it is also important to implement Deferred behavior.

We have task.defer, and it is also possible to infer what mode the game is in with some simple code. I did this in my Signal library which is useful to implementing this. You can use it if you like (I don't maintain it, running Linux can't anymore, it doesn't have the same typing as sleitnick's fork for example) or fork/use the ideas/code from there. (I think so anyway? I haven't looked at licenses for a while but I can probably change it for this if it is an issue)

Thank you for your time.

lucasmz-dev commented 6 months ago

Furthermore, devs testing Deferred behavior with how it works right now might make some issues appear that are hard to debug, such as race conditions, or issues with expectation of order, as events from the game itself, would run in Deferred, while Nevermore's Signal would be running Immediate.