Repair error caused by collecting fields too early in during

This commit is contained in:
Tony Garnock-Jones 2021-01-29 15:36:53 +01:00
parent 7423479de3
commit a64a8177eb
1 changed files with 1 additions and 2 deletions

View File

@ -198,13 +198,12 @@ export function expand(tree: Items, ctx: ExpansionContext): Items {
} else {
// TODO: untyped template
const sa = compilePattern(s.pattern);
const body = ctx.withCollectedFields(s.facetFields, () => walk(s.body));
return t`withSelfDo(function (thisFacet) {
const _Facets = new __SYNDICATE__.Dictionary<__SYNDICATE__.Facet<any>>();
on asserted ${patternText(s.pattern)} => react {
_Facets.set([${commaJoin(sa.captureBinders.map(t=>[t.id]))}], thisFacet);
dataflow { } // TODO: horrible hack to keep the facet alive if no other endpoints
${body}
${s.body}
}
on retracted ${patternText(s.pattern)} => {
const _Key = [${commaJoin(sa.captureBinders.map(t=>[t.id]))}];