Skip to content
This repository was archived by the owner on Aug 20, 2022. It is now read-only.
This repository was archived by the owner on Aug 20, 2022. It is now read-only.

Attempt to support initial frame instance  #21

@rdev34

Description

@rdev34

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 environment

Metadata

Metadata

Assignees

Labels

pre-releaseComplete before the official release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions