pub const BIND: FunctionDescriptor;Expand description
Binds a concrete entity component so extracted methods can update that live component transactionally.
C means a concrete type selector, never a trait. The reference owns an entity and component identity; extracted mutating methods commit back transactionally and fail if the component is unavailable.
§Signature
func bind[C](entity: Entity) -> ComponentReference[C]§Bind a live component
A bound mutating method commits its component update.
type Counter { value: Number = 0; func advance() -> Res[Unit, DataError] { self.value = (self.value + 1)?; ret Ok(()); } }
let entity = spawn(Counter {});
let reference = bind[Counter](entity);
let advance = reference.advance;
advance()?;
print(get[Counter](entity).value);