Mercurial > code > home > repos > light9
changeset 2272:9ca3d356b950
attempted rewrite of rerunInners
author | drewp@bigasterisk.com |
---|---|
date | Mon, 29 May 2023 13:24:01 -0700 |
parents | 698da65519a3 |
children | 4074dbec5c46 |
files | light9/web/AutoDependencies.ts |
diffstat | 1 files changed, 13 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/AutoDependencies.ts Mon May 29 13:23:16 2023 -0700 +++ b/light9/web/AutoDependencies.ts Mon May 29 13:24:01 2023 -0700 @@ -95,40 +95,31 @@ prn(this.handlers, ""); } - _handlerIsAffected(child: Handler, patchSubjs: Set<string>) { - if (patchSubjs === null) { - return true; - } - if (!child.patterns.length) { - return false; - } - - for (let stmt of Array.from(child.patterns)) { - if (stmt.subject === null) { - // wildcard on subject - return true; - } - if (patchSubjs.has(stmt.subject.value)) { + _handlerIsAffected(child: Handler, patch: Patch): boolean { + // it should be correct but slow to always return true here + for (let pat of child.patterns) { + if (patch.matches(pat)) { return true; } } - return false; } graphChanged(patch: Patch) { // SyncedGraph is telling us this patch just got applied to the graph. - const subjs = allPatchSubjs(patch); var rerunInners = (cur: Handler) => { const toRun = cur.innerHandlers.slice(); for (let child of Array.from(toRun)) { - //match = @_handlerIsAffected(child, subjs) - //continue if not match - //log('match', child.label, match) - //child.innerHandlers = [] # let all children get called again - this._rerunHandler(child, patch); - rerunInners(child); + const match = this._handlerIsAffected(child, patch); + + if (match) { + log("match", child.label, match); + child.innerHandlers = []; // let all children get called again + this._rerunHandler(child, patch); + } else { + rerunInners(child); + } } }; rerunInners(this.handlers);