Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

onTraitChange

onTraitChange(world, trait, listener): () => void

Koota’s world.onChange, which also takes a predicted or a core trait and the read-only world a view holds, since listening writes nothing: calls listener with each entity whose record of trait is set, as it is set, and returns the call that stops it. A HUD hears a player’s connection drop with onTraitChange(world, ConnectionTrait, notify), to show a line for each drop; a value it draws, such as a count of the connected, reads with useWorldRead.

Parameter Type
world World
trait Trait | PredictedTrait<any> | CoreTrait<any>
listener (entity) => void

() => void