Skip to main content

GET

Constant GET 

Source
pub const GET: FunctionDescriptor;
Expand description

Reads a typed component copy from an entity; the entity must have that component.

C means a concrete type selector. The result is a component copy; update the live entity with set, or use a system binding or bind[C](entity) method callback for persistent mutation.

§Signature

func get[C](entity: Entity) -> C

§Select a component

The explicit selector fixes the component type for a function value.

type Counter { value: Number = 2; }
let entity = spawn(Counter {});
let read: func(Entity) -> Counter = get[Counter];
print(read(entity).value);