Skip to content

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

@suchipi

Description

@suchipi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2dRelated to @hex-engine/2ddocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions