Better Ref printing
This commit is contained in:
parent
ffee492fec
commit
b5e82cba9b
|
@ -34,6 +34,31 @@ export interface Ref {
|
||||||
readonly attenuation?: Attenuation;
|
readonly attenuation?: Attenuation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class RefImpl implements Ref {
|
||||||
|
readonly relay: Facet;
|
||||||
|
readonly target: Partial<Entity>;
|
||||||
|
readonly attenuation?: Attenuation;
|
||||||
|
|
||||||
|
constructor(relay: Facet, target: Partial<Entity>, attenuation?: Attenuation) {
|
||||||
|
this.relay = relay;
|
||||||
|
this.target = target;
|
||||||
|
this.attenuation = attenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
toString() {
|
||||||
|
let entityRepr = '' + this.target;
|
||||||
|
if (entityRepr === '[object Object]') {
|
||||||
|
entityRepr = '#' + embeddedId(this.target);
|
||||||
|
}
|
||||||
|
let sig = '';
|
||||||
|
if ('assert' in this.target) sig = sig + 'A';
|
||||||
|
if ('retract' in this.target) sig = sig + 'R';
|
||||||
|
if ('message' in this.target) sig = sig + 'M';
|
||||||
|
if ('sync' in this.target) sig = sig + 'S';
|
||||||
|
return `⌜${this.relay.idChain()}<${sig}>${entityRepr}⌝`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
export function isRef(v: any): v is Ref {
|
export function isRef(v: any): v is Ref {
|
||||||
|
@ -262,7 +287,7 @@ export class Turn {
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<T extends Partial<Entity>>(e: T): Ref {
|
ref<T extends Partial<Entity>>(e: T): Ref {
|
||||||
return { relay: this.activeFacet, target: e };
|
return new RefImpl(this.activeFacet, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
facet(bootProc: LocalAction): Facet {
|
facet(bootProc: LocalAction): Facet {
|
||||||
|
|
Loading…
Reference in New Issue