Simplify
This commit is contained in:
parent
4c5f896ecf
commit
4c0e2b448e
8
actor.ts
8
actor.ts
|
@ -30,7 +30,7 @@ export class Ref<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OutboundMap = Map<Handle, [Ref<Entity>, Assertion]>;
|
export type OutboundMap = Map<Handle, Ref<Entity>>;
|
||||||
|
|
||||||
export class Actor {
|
export class Actor {
|
||||||
readonly outbound: OutboundMap;
|
readonly outbound: OutboundMap;
|
||||||
|
@ -47,7 +47,7 @@ export class Actor {
|
||||||
terminateWith(t: Turn, reason: Exclude<ExitReason, null>) {
|
terminateWith(t: Turn, reason: Exclude<ExitReason, null>) {
|
||||||
if (this.alive) {
|
if (this.alive) {
|
||||||
this.exitReason = reason;
|
this.exitReason = reason;
|
||||||
this.outbound.forEach(([peer, _a], h) => t._retract(peer, h));
|
this.outbound.forEach((peer, h) => t._retract(peer, h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ export class Turn {
|
||||||
assert(location: Ref<Entity>, assertion: Assertion): Handle {
|
assert(location: Ref<Entity>, assertion: Assertion): Handle {
|
||||||
const h = nextHandle++;
|
const h = nextHandle++;
|
||||||
this.enqueue(location.actor, t => {
|
this.enqueue(location.actor, t => {
|
||||||
this._ensureActor("assert").outbound.set(h, [location, assertion]);
|
this._ensureActor("assert").outbound.set(h, location);
|
||||||
location.target[assert]?.(t, assertion, h);
|
location.target[assert]?.(t, assertion, h);
|
||||||
});
|
});
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
retract(h: Handle): void {
|
retract(h: Handle): void {
|
||||||
this._retract(this._ensureActor("retract").outbound.get(h)![0], h);
|
this._retract(this._ensureActor("retract").outbound.get(h)!, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
replace(location: Ref<Entity>, h: Handle | undefined, assertion: Assertion): Handle {
|
replace(location: Ref<Entity>, h: Handle | undefined, assertion: Assertion): Handle {
|
||||||
|
|
Loading…
Reference in New Issue