useWorldRead
useWorldRead<
Value>(read):Value
read’s answer over the world, read again after each step of the
world, once a frame while it stands still, and after a write between
steps, and drawn again when the answer changes. The answer compares by
value: a count, a flag, an entity, or a list or plain record of them,
made fresh on each read, such as a scoreboard’s rows, draws again only
when a value in it changes. Return values rather than a record the
world holds, which changes in place and so always compares the same.
A HUD counts across many entities with it, such as the players ready:
useWorldRead((world) => world.query(ReadyTrait).length). As
zustand’s useStore(selector) and Redux’s useSelector read their
store again on each change.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Value |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
read |
(world) => Value |
Returns
Section titled “Returns”Value