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

Attempt to support initial frame instance #21

Open
rdev34 opened this issue Dec 17, 2020 · 0 comments
Open

Attempt to support initial frame instance #21

rdev34 opened this issue Dec 17, 2020 · 0 comments
Assignees
Labels
pre-release Complete before the official release

Comments

@rdev34
Copy link
Collaborator

rdev34 commented Dec 17, 2020

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

@rdev34 rdev34 self-assigned this Dec 17, 2020
@rdev34 rdev34 added the pre-release Complete before the official release label Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pre-release Complete before the official release
Projects
None yet
Development

No branches or pull requests

1 participant