This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
Attempt to support initial frame instance #21
Labels
pre-release
Complete before the official release
Currently we collect class instance initializations of the first frame until all files are loaded, and after that we run the constructors.
However a valid use case would be to initialize a class instance on the first frame and call a function on it, and that doesn't work properly right now because the function would be called before the constructor runs.
Currently the advantage of collecting the constructors is that we can stall the initialization of client-side code until data is fetched. One way we use this is to ensure all Player data is available in constructors on the client, and we don't want to lose that functionality.
Potential solution: Temporarily define __call metatable event on non-initialized class instances and remove this when initialization is complete. In the intercept code, we check if the class instance has initialized, and if not, we immediately run the constructor for that class instance. Also we can add a warning/error message that it's not recommended to use a class instance on the first frame since other constructors have not executed, and that the function call on that instance should be moved inside of a
Events:Subscribe("ClientReady", function() end)
block so that it has access to the entire initialized environmentThe text was updated successfully, but these errors were encountered: