23 lines
618 B
TypeScript
23 lines
618 B
TypeScript
|
|
// ── Relationship ─────────────────────────────────────
|
||
|
|
/**
|
||
|
|
* A relationship definition — like a component, but represents a directed
|
||
|
|
* link between two entities.
|
||
|
|
*
|
||
|
|
* @example
|
||
|
|
* ```ts
|
||
|
|
* const ChildOf = defineRelationship();
|
||
|
|
* world.relate(child, ChildOf, parent);
|
||
|
|
* ```
|
||
|
|
*/
|
||
|
|
export interface RelationshipDef {
|
||
|
|
/** Unique symbol used as the storage key. */
|
||
|
|
readonly _key: symbol;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Define a named relationship between entities.
|
||
|
|
*/
|
||
|
|
export function defineRelationship(): RelationshipDef {
|
||
|
|
return { _key: Symbol() };
|
||
|
|
}
|