DependencyNode.js 846 B

123456789101112131415161718192021222324252627282930313233
  1. class DependencyNode {
  2. constructor({ parentNode, model, modelClass, relation, dataPath }) {
  3. this.id = model[modelClass.uidProp];
  4. this.parentNode = parentNode || null;
  5. this.model = model;
  6. this.modelClass = modelClass;
  7. this.relation = relation || null;
  8. this.dataPath = dataPath;
  9. this.needs = [];
  10. this.isNeededBy = [];
  11. this.manyToManyConnections = [];
  12. this.numHandledNeeds = 0;
  13. this.handled = false;
  14. this.visited = false;
  15. this.recursion = false;
  16. }
  17. get hasUnresolvedDependencies() {
  18. return this.numHandledNeeds < this.needs.length;
  19. }
  20. markAsInserted() {
  21. for (let nb = 0, lnb = this.isNeededBy.length; nb < lnb; ++nb) {
  22. const dependency = this.isNeededBy[nb];
  23. dependency.node.numHandledNeeds++;
  24. }
  25. this.handled = true;
  26. }
  27. }
  28. module.exports = DependencyNode;