diff --git a/src/nub.ts b/src/nub.ts index 43970a54e102804ab30088d383b8e0af628c7806..fa0b60454794f0b9f30d4667fc4ce20583686998 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -578,6 +578,27 @@ export abstract class Nub extends ComputeNode implements IObservable { return requiredNubs; } + /** + * Returns all Nubs whose parameters or results are targettes + * by the given one. + * (used for dependencies checking at session saving time) + */ + public getTargettedNubs(visited: string[] = []) { + const targettedNubs: Nub[] = []; + // prevent loops + if (! visited.includes(this.uid)) { + visited.push(this.uid); + + // inspect all target Nubs + for (const p of this.parameterIterator) { + if (p.valueMode === ParamValueMode.LINK && p.isReferenceDefined()) { + targettedNubs.push(p.referencedValue.nub); + } + } + } + return targettedNubs; + } + /** * Returns true if * - this Nub