updateEach
updateEach<
T>(world,query,callback):void
Walks each entity query matches, hands its traits’ fields to
callback, and writes back what the callback changed:
updateEach(world, lamps, ([lamp]) => { if (!lamp.isLit) lamp.isLit = true; })
lights every lamp, with lamps made once as createQuery(LampTrait).
It reads as readEach does, then writes each trait back as koota’s
updateEach does: a trait something watches is compared and, where it changed, its
watchers are told once the pass ends; every other is written back
unread. On a query of traits and Not alone, a Changed query is not
told, so it holds the same entities whether a view watches or not: use
entity.set for a write a Changed query must see. A query with Or,
a tracking modifier or a relation runs koota’s own updateEach, which
tells both while something watches. An entity the callback destroyed is
skipped.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends QueryParameter[] |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
world |
World |
query |
Query<T> |
callback |
EachCallback<T> |
Returns
Section titled “Returns”void