Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "lifecycle" doc explaining when and how often component functions are called, and how hook functions interact with frames #18

Open
suchipi opened this issue Feb 1, 2020 · 0 comments
Labels
2d Related to @hex-engine/2d documentation Improvements or additions to documentation

Comments

@suchipi
Copy link
Owner

suchipi commented Feb 1, 2020

The docs don't make it clear that component functions only run once, when the component is created. That's different from React, so it's important to point out.

Also, for hooks that run every frame, it'd be good to add something to the docs that explains when they run, ideally with a visualization.

For the sake of writing the hooks doc later, the pseudocode is:

every frame:
  for every entity in the scene, in creation order:
    for every component on this entity, in creation order:
      run any functions registered by useUpdate, in the order they were registered

  call useCanvasDrawOrderSort, passing in every entity in the scene, in creation order. it returns an array of components, in the order they should be drawn
  for every component in the returned array:
    run any functions registered by useDraw (or useRawDraw), in the order that they were registered

NOTE: useDraw is a thin wrapper around useRawDraw.
@suchipi suchipi added documentation Improvements or additions to documentation 2d Related to @hex-engine/2d labels Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2d Related to @hex-engine/2d documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant