vega-dataflow
Version:
Reactive dataflow processing.
20 lines (18 loc) • 604 B
JavaScript
/**
* Connect a target operator as a dependent of source operators.
* If necessary, this method will rerank the target operator and its
* dependents to ensure propagation proceeds in a topologically sorted order.
* @param {Operator} target - The target operator.
* @param {Array<Operator>} - The source operators that should propagate
* to the target operator.
*/
export default function(target, sources) {
const targetRank = target.rank,
n = sources.length;
for (let i = 0; i < n; ++i) {
if (targetRank < sources[i].rank) {
this.rerank(target);
return;
}
}
}